Hi Programmers, Actually I have a DataGridViewComboBoxCell in DataGridvIew and I need to change the DataGridViewComboBox value if the condition is true when the CellContentClick event is fired. My Code Goes Like this:
private void gridviewholiday_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
int row = e.RowIndex;
int colo = e.ColumnIndex;
/*=============== To Show The Details =====================*/
if (e.ColumnIndex == 4)
{
if (Convert.ToBoolean(gridviewholiday.Rows[e.RowIndex].Cells[0].Value))
{
if (Type == "CUS")
{
Type = test.colType;
if (Type == "NO")
{
ComboBox combo = (ComboBox)sender;
combo.SelectedIndex = 0;
}
}
}
But it gives error while casting DataGridView to Combobox.
Please help me out.