dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: [RESOLVED] DataGridViewComboBox event

  1. #1
    Join Date
    Aug 2009
    Location
    NW USA
    Posts
    173

    [RESOLVED] DataGridViewComboBox event

    I have a DGV with a CB column in VS2008. I would like an event when a DGVCB selection is made (without leaving the cell). It will probably have to be a DGV cell or row event but I can't find one that fires as soon as a DGVCB selection is made. thx

  2. #2
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    149

    Re: DataGridViewComboBox event

    One way of achieving the same is as below:
    Code:
    Public Class Form1
        Dim WithEvents MyCbo As ComboBox
    
        Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
            If TypeOf e.Control Is ComboBox Then
    
                MyCbo = DirectCast(e.Control, ComboBox)
    
            End If
    
        End Sub
    
        Private Sub MyCbo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyCbo.SelectedIndexChanged
            MsgBox(MyCbo.Items(MyCbo.SelectedIndex))
        End Sub
    End Class
    Working fine in VB.Net 2005 and framework 2.0.

    It should work in VS2008 also.
    Good luck
    Encourage the efforts of fellow members by rating

    Lets not Spoon Feed and create pool of lazy programmers

    - ComIT Solutions

  3. #3
    Join Date
    Aug 2009
    Location
    NW USA
    Posts
    173

    Re: DataGridViewComboBox event

    Peerrrrfect. thx

  4. #4
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    149

    Re: DataGridViewComboBox event

    Quote Originally Posted by Mur16 View Post
    Peerrrrfect. thx
    If you got what you were looking for,mark this thread as resolved.
    Encourage the efforts of fellow members by rating

    Lets not Spoon Feed and create pool of lazy programmers

    - ComIT Solutions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)