Quantcast
Viewing all articles
Browse latest Browse all 12583

Save combobox.SelectedIndex in Properties.Settings.Default... for future sessions.

Hello,

the goal is to save the combobox-index into PropertiesSettings  to keep the settings for future sessions.

That is working properly. Let's say the chosen index is 2.

When reloading the form, the first messageBox (see code) reveals the correct value 2.

The second messageBox always shows 0.

I narrowed down the combobox.DataSource-line as the one that zero-fills my properties.

But now I'm helpless.

Any ideas?

S.

private void frm1_Load(object sender, EventArgs e)
        {
            MessageBox.Show(Properties.Settings.Default.comboboxIndex.ToString());   //  2
            comboBox1.DataSource = Enum.GetValues(typeof(myEnum));
            comboBox1.SelectedIndex = Properties.Settings.Default.ComboBoxIndex;      // selectedInded == 0

            MessageBox.Show(Properties.Settings.Default.ComboBoxIndex.ToString()); // 0

..


Viewing all articles
Browse latest Browse all 12583

Trending Articles