Hi I have a datagridview (winform) inside it I have a cell type( DataGridViewComboBoxCell ) i want to bind the value in this combox cell according to the previous cell value.
I have done the following coding for bind it I have tried this on RowEnter event but it fire again and again on click etc..
So i don't want to use this event. Can any one tell me the best event on which i can put my following code...
List<int> k = new List<int>();
int value = Convert.ToInt32( dgvDisplayAvailRoom.Rows[e.RowIndex].Cells[4].Value);
for (int i = 1; i <= value; i++)
{
k.Add(i);
}
DataGridViewComboBoxCell cmb = (DataGridViewComboBoxCell)dgvDisplayAvailRoom.Rows[e.RowIndex].Cells[5];

Vikas AhlawatPosted Jun 25, 2012, 2:02 AM
private void BindComboBox()
{
for (int i = 0; i < dgvDisplayAvailRoom.Rows.Count; i++)
{
List<int> k = new List<int>();
int value = Convert.ToInt32(dgvDisplayAvailRoom.Rows[i].Cells[4].Value);
for (int j = 1; j <= value; j++)
{
k.Add(i);
}
DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dgvDisplayAvailRoom.Rows[i].Cells[5];
cell.DataSource = k;
}
}
This is not binding data why?
Sudhakar ChaudharyPosted Jun 18, 2012, 12:05 AM
private void GetFallon()
{
try
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
SqlDataAdapter adp = new SqlDataAdapter("SELECT F_FALLON FROM AMS WHERE A_CODE='" + dataGridView1.Rows[i].Cells[6].Value.ToString() + "'", con);
DataSet ds = new DataSet();
adp.Fill(ds, "s");
string Fallon = ds.Tables["s"].Rows[0].ItemArray[0].ToString();
DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dataGridView1.Rows[i].Cells[3];
if (Fallon == "A")
{
cell.Value = "ASSET";
}
else if (Fallon == "L")
{
cell.Value = "LIAL";
}
else if (Fallon == "I")
{
cell.Value = "INCOME";
}
else if (Fallon == "E")
{
cell.Value = "EXPENDITURE";
}
}
}
catch (Exception ms) { }
}