I want to show an combobox and show all its elements when users click the cell in the datatable.
The problem is when I click the cell, the combobox does not appear.
But after I click the second cell, the combobox in the first cell appears.
Then, I need to click the combobox twice to display all the elements.
What is the problem and how to solve it?
Here is my code.
private DataTable GetInfoTable()
{
DataTable l_dtInfo = new DataTable();
l_dtInfo .Columns.Add("Info", typeof(string));
l_dtInfo .Rows.Add("11-20");
l_dtInfo .Rows.Add("21-30");
l_dtInfo .Rows.Add("31-40");
return l_dtInfo ;
}
private void editValue(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridView grid = sender as DataGridView;
if (e.ColumnIndex > -1)
{
DataGridViewComboBoxCell l_objGridDropbox = new DataGridViewComboBoxCell();
grid[e.ColumnIndex, e.RowIndex] = l_objGridDropbox;
l_objGridDropbox.DataSource = GetInfoTable();
l_objGridDropbox.ValueMember = "Info";
l_objGridDropbox.DisplayMember = "Info";
}
}