Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dataGridView in windows.

In the dataGridView i have a combox.
Now i populate values in this combobox,

so initially i fill values in Datatable,

SqlConnection objConn = new SqlConnection(fstrConn);
SqlDataAdapter objDA;
DataTable DTResult = new DataTable();

objDA = new SqlDataAdapter(fstrSQL, fstrConn);
objDA.Fill(DTResult);

Next in dataGridView_CellBeginEdit event i am populating values to combobox,

private void dataGridView_CellBeginEdit(object sender,DataGridViewCellCancelEventArgs e)
{
DataGridViewComboBoxCell objCbo=new DataGridViewComboBoxCell();
objCbo=(DataGridViewComboBoxCell)dataGridView.Rows[e.RowIndex].Cells[0];

C#
for (int i = 0; i < DTResult.Rows.Count; i++)
{
    objCbo.Items.Add(DTResult.Rows[i][ColumnName].ToString());
    objCbo.DisplayMember = ColumnName;
    objCbo.ValueMember = ColumnName;
}


}


after this when i select a value in this combobox,
i need to get the value of valuemember.

so plz help me.......
thanks n advnz..........
Posted

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



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