Results 1 to 9 of 9

Thread: ToolStripComboBox behavior different than ComboBox

  1. #1

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    ToolStripComboBox behavior different than ComboBox

    I have a bound ToolStripComboBox. When a user types a value and hits 'Enter', assuming the entered value is an item in the ComboBox, this Sub should fire:


    vb Code:
    1. Private Sub tsbCmbMHSJob_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbCmbMHSJob.SelectedIndexChanged
    2.  
    3.      FilterMHSJobDV()
    4.  
    5. End Sub


    The problem I'm encountering is that with the ToolStripComboBox when the user enters a valid value and hits 'Enter' nothing happens. If I enter the value, then tab to the next control and hit enter, it fires.


    When I use the "SelectedIndexChanged" Event in a standard ComboBox, entering the value and hitting enter triggers this event.


    How can I get the ToolStripComboBox to behave like the standard ComboBox?
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  2. #2

    Re: ToolStripComboBox behavior different than ComboBox

    Perhaps on keydown, see if Enter was pressed and cause the control to lose focus?

  3. #3

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: ToolStripComboBox behavior different than ComboBox

    That seems like a work-around to something that could be handled differently... I could be wrong.

    I'm searching now for the difference between the two types of ComboBoxes.

    Thanks for your input, that may be the only way to make it work. Hope not.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: ToolStripComboBox behavior different than ComboBox

    A ToolStripComboBox is not a ComboBox. It's a ToolStripControlHost that customised to host a ComboBox. The ToolStripComboBox class has a ComboBox property, which return a reference to the hosted ComboBox control.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: ToolStripComboBox behavior different than ComboBox

    Are you saying that there is not an event I can handle, etc., to make the ToolStripComboBox behave as I've described?

    Some of my Users do not use a mouse to select an item in the ComboBox drop down, they enter it in the visible TextBox, hit enter and expect that trigger the method.
    Last edited by jazFunk; Jul 21st, 2010 at 08:01 PM. Reason: error
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  6. #6

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: ToolStripComboBox behavior different than ComboBox

    Also, I tried to address the ComboBox property of the ToolStripComboBox, but it does not exist in my properties window, or intellisense.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: ToolStripComboBox behavior different than ComboBox

    As I said:
    The ToolStripComboBox class has a ComboBox property, which return a reference to the hosted ComboBox control.
    Anything you can't do through the ToolStripComboBox itself you can do through that ComboBox.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: ToolStripComboBox behavior different than ComboBox

    Quote Originally Posted by jazFunk View Post
    Also, I tried to address the ComboBox property of the ToolStripComboBox, but it does not exist in my properties window, or intellisense.
    It's not visible in the Properties window because the property has its Browsable attribute set to False, which specifically hides it from designers.

    As for Intellisense, it IS visible. If you can't see it then you're just looking in the wrong place. Are you actually trying to access it via a ToolStripComboBox reference? I'll wager not. I'll bet that you're using a ToolStripItem reference. The ToolStripItem has no such member so Intellisense won't display it for that type.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: ToolStripComboBox behavior different than ComboBox

    In the first screen shot IntelliSense shows that my control is indeed a ToolStripComboBox


    The 2nd screen shot shows the ComboBox property available inside the SelectedIndexChanged Event of the ToolStripComboBox ("tsbCmbMHSJob")



    One other thing I must mention, and just rediscovered, is that I'm handling the MouseUp Event in different Method which does my DataBinding.

    I made this part of the Form some time ago and I believe I did it this way so that when the Form loaded it wouldn't populate Data until a Job# was selected. I've since learned to how to remove the Handler and add it back to accomplish but haven't rewritten. Could this be causing a conflict?

    Here's the code:

    vb Code:
    1. Private Sub BindMHSJobs(ByVal sender As Object, ByVal e As System.EventArgs) _
    2.                 Handles tsbCmbMHSJob.MouseUp
    3.  
    4.         If Me.tsbCmbMHSJob.ComboBox.Items.Count < 1 Then
    5.  
    6.             ' Populate tsbCmbMHSJob combo box
    7.             With Me.tsbCmbMHSJob
    8.                 .ComboBox.DataSource = mhsJobDT
    9.                 .ComboBox.DisplayMember = "mhsJob"
    10.             End With
    11.  
    12.             ' Clear DataBinding
    13.             Me.lblCustJob.DataBindings.Clear()
    14.             Me.lblCust.DataBindings.Clear()
    15.             Me.lblJobDesc.DataBindings.Clear()
    16.             Me.lblProjNum.DataBindings.Clear()
    17.             Me.lblStateNum.DataBindings.Clear()
    18.             Me.lblCompDate.DataBindings.Clear()
    19.             Me.ckbActive.DataBindings.Clear()
    20.             Me.ckbMMM.DataBindings.Clear()
    21.  
    22.             ' Add DataBinding
    23.             Me.lblCustJob.DataBindings.Add("Text", mhsJobDT, "custJob")
    24.             Me.lblCust.DataBindings.Add("Text", mhsJobDT, "cust")
    25.             Me.lblJobDesc.DataBindings.Add("Text", mhsJobDT, "jobDesc")
    26.             Me.lblProjNum.DataBindings.Add("Text", mhsJobDT, "projNum")
    27.             Me.lblStateNum.DataBindings.Add("Text", mhsJobDT, "stateNum")
    28.  
    29.             ' Format Date
    30.             Me.lblCompDate.DataBindings.Add("Text", mhsJobDT, "compDate", True).FormatString = "MM/dd/yyyy"
    31.             Me.ckbActive.DataBindings.Add("Checked", mhsJobDT, "Active")
    32.             Me.ckbMMM.DataBindings.Add("Checked", mhsJobDT, "MMMDisc")
    33.  
    34.             ' Testing
    35.             Me.tsbCmbMHSJob.DroppedDown = True
    36.  
    37.  
    38.         End If
    39.  
    40. End Sub
    Attached Images Attached Images   
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

Posting Permissions

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



Click Here to Expand Forum to Full Width