title: How to Get comboBox value from a datagridview cell
body: <p>I want to get value  of a <code>ComboBox</code> cell in the <code>DataGridView</code> to put it in a Update method for the record. Values for this <code>ComboBox</code> are displayed with <code>DisplayMember</code> and are stored in the database as <code>ID</code>.</p>
  
  <p>This is a <code>ComboBox</code> in my <code>DataGridView</code> in my form load method with the <code>ComboBox</code> cell at Index 15</p>
  
  <pre><code>.............
          dgv_Cust.Columns[14].Name="Web";
          dgv_Cust.Columns[14].DataPropertyName = "Web";
          DataGridViewComboBoxColumn cbcol = new DataGridViewComboBoxColumn();
          cbcol.Name = "AccStatus";
  
          cbcol.DataPropertyName = "cbcol"; // DataTable column name
          cbcol.Items.Add(new ComboRecord(0, ""));
          cbcol.Items.Add(new ComboRecord(1, "Active"));
          cbcol.Items.Add(new ComboRecord(2, "NotActive"));
          cbcol.Items.Add(new ComboRecord(3, "Other"));
          cbcol.DisplayMember = "Status";
          cbcol.ValueMember = "IDx";
          cbcol.DisplayIndex = 15;
          dgv_Cust.Columns.Add(cbcol);
  
          dgv_Cust.Columns[15].Name = "AccStatus";
          dgv_Cust.Columns[15].DataPropertyName = "AccStatus";
  
          dgv_Cust.ColumnCount = 17;
  
  
          dgv_Cust.Columns[16].Name="Location";
          dgv_Cust.Columns[16].DataPropertyName = "Location";
  
          dgv_Cust.DataSource = DBConn.getCustInfo1();
      }
  </code></pre>
  
  <p>I am getting values from this <code>DataGridView</code> to pass it to the Update method like this.....</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)   //UpdateCustomer
  {
  
        //Here I want to get valueMember(IDx) for cell[15], from the comboBox          
  
          string PostalCode = this.dgv_Cust.CurrentRow.Cells[2].Value.ToString();
          string Name = this.dgv_Cust.CurrentRow.Cells[3].Value.ToString();
          string BusinessName = this.dgv_Cust.CurrentRow.Cells[4].Value.ToString();
          string AltName = this.dgv_Cust.CurrentRow.Cells[5].Value.ToString();
          string Adrs1 = this.dgv_Cust.CurrentRow.Cells[6].Value.ToString();
          string Adrs2 = this.dgv_Cust.CurrentRow.Cells[7].Value.ToString();
          string City = this.dgv_Cust.CurrentRow.Cells[8].Value.ToString();
          string Province = this.dgv_Cust.CurrentRow.Cells[9].Value.ToString();
          string Phone1 = this.dgv_Cust.CurrentRow.Cells[10].Value.ToString();
          string Phone2 = this.dgv_Cust.CurrentRow.Cells[11].Value.ToString();
          string Email1 = this.dgv_Cust.CurrentRow.Cells[12].Value.ToString();
          string Email2 = this.dgv_Cust.CurrentRow.Cells[13].Value.ToString();
          string Web = this.dgv_Cust.CurrentRow.Cells[14].Value.ToString();
          string Location = this.dgv_Cust.CurrentRow.Cells[16].Value.ToString();
  
  
          try
          {
  
  
              DBConn.updateCustInfo1(AccStatus, PostalCode, Name, BusinessName, AltName, Adrs1, Adrs2, City, Province, Phone1, Phone2, Email1, Email2, Web, Location);
          }
          catch (Exception es)
          {
              MessageBox.Show(es.Message);
  
          }
  </code></pre>
  
  <p>How do I get <code>ValueMember(IDx)</code> from the <code>DisplayMember</code>("", "Active", "NotActive", "Other") of the <code>ComboBox</code> in the <code>DGV</code> as <code>ComboBox</code> value is stored as '<code>IDx</code>' in the database.</p>