Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » [SOLVED] DataGridViewComboBoxColumn change to automatically update DataGridView


DataGridViewComboBoxColumn change to automatically update DataGridView

Reply
  #1 (permalink)  
Old 01-24-10, 10:28 PM
tim8w tim8w is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
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...
Reply With Quote
  #2 (permalink)  
Old 01-25-10, 12:34 AM
tim8w tim8w is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
Wink Resolved

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
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP, copyright.js script needs year to automatically change. myWebsearch JavaScript 4 10-24-09 11:58 PM
Database Change, PHP Auto Update?? memphis2k PHP 4 02-22-08 04:47 AM
Does rss automatically update? sammie85uk The Lounge 3 01-25-08 06:48 AM
Update multiple rows outside loop - need help ElvansX PHP 1 12-03-06 01:55 AM


All times are GMT -5. The time now is 02:19 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.