title: How to Create New User Setting in app.config at Run Time
body: <p>I have an Editable ComboBox. The user enters text and presses a Save button. Their text is turned into a string.</p>
  
  <p>I need it at Run Time to Create a new User Setting to the app.config with the name of their string. (I think this part works now).</p>
  
  <p>Then another ComboBox's Selected Item is saved to the Setting. (Object reference not set error).</p>
  
  <p>This is to create a custom preset that will save each control state, checkboxes, textboxes, etc. in the program. </p>
  
  <pre><code>// Control State to be Saved to Setting
  Object comboBox2Item = ComboBox2.SelectedItem;
  
  // User Custom Text
  string customText = ComboBox1.Text;
  
  // Create New User Setting
  var propertyCustom = new SettingsProperty(customText);
  propertyCustom.Name = customText;
  propertyCustom.PropertyType = typeof(string); 
  Settings.Default.Properties.Add(propertyCustom);
  
  // Add a Control State (string) to the Setting
  Settings.Default[customText] = (string)comboBox2Item;
  </code></pre>
  
  <p>At this part I get an error.</p>
  
  <pre><code>Settings.Default[customText] = (string)comboBox2Item;
  </code></pre>
  
  <p><strong>Exception:Thrown: "Object reference not set to an instance of an object."</strong></p>
  
  <p>I have tried setting ComboBox1.Text to an Object instead of string, with same error. The text and string is also not null.</p>
  
  <pre><code>Object customText = ComboBox1.Text;
  </code></pre>
  
  <p><strong>Here's a visual of what I'm trying to do</strong>
  <a href="https://i.stack.imgur.com/52rtF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/52rtF.png" alt="Custom User Setting"></a></p>