Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
setting section:
C#
public string cmb
     {
         get
         {
             return ((string)(this["cmb"]));
         }
         set
         {
             this["cmb"] = value;
              
         }
     }


app.config section:
HTML
<configSections>
      <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
        <section name="test_TextBox.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
      </sectionGroup>
    </configSections>
  <userSettings>
    <test_TextBox.Properties.Settings>
      <setting name="cmb" serializeAs="String">
        <value />
      </setting>
    </test_TextBox.Properties.Settings>
  </userSettings>


run code:
C#
private void TXTvolt_KeyPress(object sender, KeyPressEventArgs e)
       {
           if (e.KeyChar==13)
           {
               if (!Properties.Settings.Default.cmb.Contains("," + TXTvolt.Text.TrimStart().TrimEnd().Trim() + ","))
               {
 
                   Properties.Settings.Default.cmb += TXTvolt.Text.TrimStart().TrimEnd().Trim() + ",";
                   Properties.Settings.Default.Save();
 
               }
               TXTvolt.Items.Add(TXTvolt.Text);
           }
       }
Posted
Comments
Sinisa Hajnal 19-Nov-14 2:22am    
Which line throws the exception? This one: Properties.Settings.Default.cmb += ...?
Member 11046620 19-Nov-14 8:48am    
error event in line: return ((string)(this["cmb"]));
BillWoodruff 19-Nov-14 3:31am    
How did you create this Setting: in code ? at design-time ?

Is this WPF ? WinForms ? ASP.NET ?

WPF, WinForms, and ASP TextBox controls do not have an 'Items property: what is 'TXTVolt here ? I guess that it's a ComboBox.
Member 11046620 19-Nov-14 8:35am    
i create this setting in code,this is winform and TXTvolt is combobox
Sinisa Hajnal 20-Nov-14 1:59am    
Then you have to show that code. Also, set one C# tag, not all of them :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900