【发布时间】:2016-03-30 04:57:35
【问题描述】:
我使用 C# 在 VS2013 中编程。我试图修改一个下拉文本框(Telerik RadDropDownListElement)。最后用户的输入将是打开软件时的默认值。
我使用 Properties.Settings.Default.var 来保存用户输入。当我将它分配给 x.Text 时,我无法再访问用户在运行时输入的文本框中的值。
public Initialize()
{
/****other initial ****/
x.Text = Properties.Settings.Default.var;
// set text to default value
}
private void save_button_Click(object sender, EventArgs e)
{
Properties.Settings.Default.var = x.Text;
//x.Test still has the default value, not the value in textbox
Properties.Settings.Default.save();
}
我尝试使用以下链接中的属性绑定,但得到了类似的结果。 Automatically update the Application Setting using the binding from VS.Net Designer
当我点击保存按钮时,如何访问文本框中的值而不是默认值?
/****编辑详细信息****/
如果我注释掉,我可以将 x.Text 保存到 varx.Text = Properties.Settings.Default.var;
但是没有显示默认值。
我使用下拉列表作为一个简单的文本框。这会产生重大影响吗?
我没有使用下拉列表的索引,只是文本。
【问题讨论】:
-
您是否有一个名为
Properties.Settins的课程,或者您的问题中只有两个拼写错误?你是输入这个还是剪切/粘贴?您是在调试器中验证 x.Text 的值(想知道您的注释代码),还是假设它已保存到您的属性中? -
@KoryGill 抱歉打错了。我输入了这个,因为另一台电脑没有互联网。我确实在调试器中验证了 x.Text 的值。
-
我用文本框替换了我所有的下拉列表,现在它可以工作了。
标签: c# winforms textbox telerik