I have three
DataGridViewComboBoxColumn
in my
DataGridView.
Based on the values selected in these column, I need to set values to the gridcells.
While doing so if the user clicks the
DataGridViewComboBoxColumn
more than once, I am getting
stackoverflow error
private void drvRtn_EditingControlShowing(object sender,DataGridViewEditingControlShowingEventArgs e)
{
if (drvRtn.CurrentCell.ColumnIndex == 21)
{
ComboBox comboBox = e.Control as ComboBox; comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
}
}
void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (drvRtn.CurrentCell.ColumnIndex == 21 )
{
int selectedIndex = ((ComboBox)sender).SelectedIndex; if (selectedIndex == 0)
{
DateTime time1 = DateTime.Now;
time1 = DateTime.Now;
drvRtn[22, 0].Value = "CONTACTABLE-NO ADD CHANGE" ;
drvRtn[21, 0].Value = "CONTACTABLE-NO ADD CHANGE" ;
string format = "HH:mm:ss";
drvRtn[19, 0].Value = time1.ToString(format);
drvRtn[18, 0].Value = time1.ToString();
drvRtn[23, 0].Value = time1.ToString();
}
}
}
private void drvRtn_CellClick_1(object sender, DataGridViewCellEventArgs e)
{
columnIndex = drvRtn.CurrentCell.ColumnIndex; if (columnIndex == 17)
{
DataGridViewComboBoxColumn colRtnRsn = new DataGridViewComboBoxColumn();
colRtnRsn.Items.AddRange("NONE", "SELF", "HUSBAND", "MOTHER", "FATHER", "SISTER");
if (Ctr2 == 0)
{ this.drvRtn.Columns.Remove("spoke_to1");
this.drvRtn.Columns.Insert(17, colRtnRsn);
Ctr2 = Ctr2 + 1;
}
}
}
Any solution to this issue will be highly appreciated.
Regards
Edward