Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# c如何将组合框SelectedIndex链接到应用程序设置_C#_Winforms_Combobox_Applicationsettingsbase - Fatal编程技术网

C# c如何将组合框SelectedIndex链接到应用程序设置

C# c如何将组合框SelectedIndex链接到应用程序设置,c#,winforms,combobox,applicationsettingsbase,C#,Winforms,Combobox,Applicationsettingsbase,在Visual Studio designer中,我使用2012,无法将应用程序设置机制链接到SelectedIndex属性纯文本 可以使用哪些变通方法 对不起,如果我的问题违反了StackOverflow规则。我搜索我的问题,没有找到确切的答案 我不知道如何自定义代码应用程序设置。我总是在设计模式下使用此功能-链接文本框的文本属性,然后使用properties.Settings.Default.Save保存此功能,在Form_Load上使用properties.Settings.Default

在Visual Studio designer中,我使用2012,无法将应用程序设置机制链接到SelectedIndex属性纯文本

可以使用哪些变通方法

对不起,如果我的问题违反了StackOverflow规则。我搜索我的问题,没有找到确切的答案

我不知道如何自定义代码应用程序设置。我总是在设计模式下使用此功能-链接文本框的文本属性,然后使用properties.Settings.Default.Save保存此功能,在Form_Load上使用properties.Settings.Default.SomeName加载保存的值。 除此之外的所有工作都是由VisualStudio完成的,我不知道到底应该如何根据我的需要改变它的行为


我确信这个问题对于开始编程的人来说是有用的,写一些代码,这和使用designer一样简单,而且designer生成了太多你不理解的代码

在Visual Studio中,添加名为SelectedIndex的属性,将其类型设置为int,范围设置为User,值设置为0,表示选择了第一项。您可以在代码中访问此属性:

public Form1()
{
    InitializeComponent();
    comboxBox1.SelectedIndex = Properties.Settings.Default.SelectedIndex;
    this.Closing += Form1_Closing;
}

void Form1_Closing(object sender, CancelEventArgs e)
{
    Properties.Settings.Default.SelectedIndex = comboxBox1.SelectedIndex;
    Properties.Settings.Default.Save();
}

当然有办法和解决办法。。。这叫做编程。你必须自己写。你能给出一个简单的例子或至少一些链接吗?不,你告诉我们你到目前为止做了什么,然后我们会提供帮助。