|
-
January 24th, 2010, 11:26 PM
#1
[RESOLVED] DataGridViewComboBoxColumn change to automatically update DataGridView
I have a standard DataGridView. One of the columns is a DataGridViewComboBoxColumn. When I select one of the ComboBox items, I want to trap the change and add additional columns based on the item selected in the ComboBox. I've tried using CellValueChanged for the DataGridView column, and a bunch of other events, but none of them is fired when the DataGridViewComboBox value is changed. What event can I trap to make this happen? Right now as I said, I am using CellValueChanged, but of course the event doesn't fire until I click on another cell...
-
January 25th, 2010, 01:35 AM
#2
Resolved: DataGridViewComboBoxColumn change to automatically update DataGridView
Here's what I had to end up doing:
Code:
Private Sub dgvClass_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvClass.EditingControlShowing
If TypeOf e.Control Is ComboBox Then
Dim combo As ComboBox = DirectCast(e.Control, ComboBox)
If combo IsNot Nothing Then
RemoveHandler combo.SelectedIndexChanged, _
New EventHandler(AddressOf ComboBox_SelectedIndexChanged)
AddHandler combo.SelectedIndexChanged, AddressOf ComboBox_SelectedIndexChanged
End If
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|