Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ToolStripComboBox.OnSelectionChangeCommitted

Status
Not open for further replies.

WMXTeam

Programmer
Oct 5, 2005
41
US
I am trying to figure out how to use ToolStripComboBox.OnSelectionChangeCommitted method with a combox in a tool strip on my form. Here is the link I found,
This is my first Windows Forms Application in VS 2010 using VB.net. I have been using ASP.net for web apps for the several years.

I have a combobox, bindNavProjectComboBox. I need to know the difference between when a user changes the combo box selection and the program does. After several days of research and trying other methods, I found OnSelectionChangeCommitted. I have added a the following to my project, but I can't figure out how to apply it to the combox

Code:
Public Class ToolStripComboBox
        Inherits System.Windows.Forms.ToolStripComboBox

        Protected Overrides Sub OnSelectionChangeCommitted(ByVal e As System.EventArgs)
            bolNavComboBoxClick = True
        End Sub

Any help is very much appreciated. I need to figure this out ASAP.
 
Fist, don't name the class the same thing as the object you are Inheriting from.

Second, I'm not sure if this is what they meant but this should work.

Code:
Public Class Form1
    WithEvents mtscb As New MyToolStripComboBox

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mtscb.Items.Add("this")
        mtscb.Items.Add("is")
        mtscb.Items.Add("a")
        mtscb.Items.Add("test")

        mtscb.Visible = True
        Me.MenuStrip1.Items.Add(mtscb)
    End Sub

    Public Sub OnSelectionChangeCommitted(ByVal e As EventArgs) Handles mtscb.SelectionChangeCommitted
        MsgBox("test")
    End Sub
End Class

Public Class MyToolStripComboBox
    Inherits System.Windows.Forms.ToolStripComboBox

    Public Event SelectionChangeCommitted(ByVal e As System.EventArgs)

    Protected Overrides Sub OnSelectionChangeCommitted(ByVal e As System.EventArgs)
        MyBase.OnSelectionChangeCommitted(e)

        RaiseEvent SelectionChangeCommitted(e)
    End Sub
End Class

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Thank you for your response. After I posted my code, I realized I had named my class the same as the object.

This is exactly what I needed. Thank you very much for your help.
 
You are welcome. :)

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top