determine selected index changed event of combo of datagridview
-
hi all, i have a datagridview in my program. i add column of combo type at run time .Now my problem is that how can i detect selected index change event of this combo.
Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company
-
hi all, i have a datagridview in my program. i add column of combo type at run time .Now my problem is that how can i detect selected index change event of this combo.
Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company
Youre trying to treat that ComboBox like it's the same one you drop on a form. It's not. That combo is buried under a DataGridViewComboBoxCell as the cell's Edit Control, which is buried under a DataGridViewComboBoxColumn. What do you think you need this for?? Under any normal circumstances, if your dataset/datatable, dgv is configured correctly, you would never need to handle this event.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Youre trying to treat that ComboBox like it's the same one you drop on a form. It's not. That combo is buried under a DataGridViewComboBoxCell as the cell's Edit Control, which is buried under a DataGridViewComboBoxColumn. What do you think you need this for?? Under any normal circumstances, if your dataset/datatable, dgv is configured correctly, you would never need to handle this event.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007use the event cellendedit. Dim indexcombo As Integer = 0
If e.ColumnIndex = 0 Then indexcombo = CType(Me.dgvTipuriColoane.Rows(e.RowIndex).Cells(e.ColumnIndex), DataGridViewComboBoxCell).Items.IndexOf(Me.dgvTipuriColoane.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString) End If valoareCombo = Me.dgvTipuriColoane.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
where the indexcombo is the index you choosed in combo. -
use the event cellendedit. Dim indexcombo As Integer = 0
If e.ColumnIndex = 0 Then indexcombo = CType(Me.dgvTipuriColoane.Rows(e.RowIndex).Cells(e.ColumnIndex), DataGridViewComboBoxCell).Items.IndexOf(Me.dgvTipuriColoane.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString) End If valoareCombo = Me.dgvTipuriColoane.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
where the indexcombo is the index you choosed in combo.That's why I asked him why he needs this. Your using an event that doesn't fire until the new value is commited to the cell. Is he looking for that?? Or is he looking to find out BEFORE the value is commited?? That's why I asked...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007