title: How to set value property of NumericUpDown from a string value?
body: <p>I want to get values from a selected row of <code>DataGridView</code> and assign them into a few different
  controls on a Form when a control's name match a column's name (there is <code>TextBox</code>, <code>ComboBox</code> and <code>NumericUpDown</code>).</p>
  
  <p>This is how I am populating the controls currently:</p>
  
  <pre><code> Form myForm = new Form();
   if (comboBoxTable.Text == "Client")
  {
         myForm = new EditClientDataWindow();
   }
  else if (comboBoxTable.Text == "Agency")
   {
         myForm = new EditAgencyDataWindow();
   }
  else if (comboBoxTable.Text == "Medicine")
   {
         myForm = new EditMedicineDataWindow();
   }
  string val;
  foreach (Control c in myForm.Controls)
  {
      for (int i = 0; i &lt; dataGridViewMDB.ColumnCount; i++)
      {
            val = dataGridViewMDB.SelectedRows[0].Cells[i].Value.ToString();
            if (dataGridViewMDB.Columns[i].Name.ToString() ==
                              c.Name.ToLower().Replace(c.GetType().ToString().ToLower().Replace("system.windows.forms.", ""), ""))
            {
            if (c is NumericUpDown)
                 (c as NumericUpDown).Value = Convert.ToInt32(val);
            else
                 c.Text = val;
            }
      }
  }
  </code></pre>
  
  <p>With the exception of <code>NumericUpDown</code>, the other types of controls are correctly populated.  For the <code>NumericUpDown</code>, I only ever get the default -1 value.  I've also tried to use <code>decimal.Parse()</code> and <code>Convert.ToDecimal()</code> instead of <code>Convert.ToInt32()</code>, but there is no change in the result.</p>
  
  <p>The range of <code>NumericUpDown</code> had been set to -1 and 999.</p>