|
-
Jul 20th, 2010, 08:10 PM
#1
Thread Starter
Hyperactive Member
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:
Private Sub tsbCmbMHSJob_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbCmbMHSJob.SelectedIndexChanged
FilterMHSJobDV()
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?
-
Jul 20th, 2010, 08:13 PM
#2
Re: ToolStripComboBox behavior different than ComboBox
Perhaps on keydown, see if Enter was pressed and cause the control to lose focus?
-
Jul 20th, 2010, 08:31 PM
#3
Thread Starter
Hyperactive Member
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.
-
Jul 20th, 2010, 11:01 PM
#4
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.
-
Jul 21st, 2010, 07:56 PM
#5
Thread Starter
Hyperactive Member
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
-
Jul 21st, 2010, 08:03 PM
#6
Thread Starter
Hyperactive Member
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.
-
Jul 21st, 2010, 08:08 PM
#7
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.
-
Jul 21st, 2010, 08:13 PM
#8
Re: ToolStripComboBox behavior different than ComboBox
 Originally Posted by jazFunk
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.
-
Jul 21st, 2010, 09:19 PM
#9
Thread Starter
Hyperactive Member
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:
Private Sub BindMHSJobs(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles tsbCmbMHSJob.MouseUp
If Me.tsbCmbMHSJob.ComboBox.Items.Count < 1 Then
' Populate tsbCmbMHSJob combo box
With Me.tsbCmbMHSJob
.ComboBox.DataSource = mhsJobDT
.ComboBox.DisplayMember = "mhsJob"
End With
' Clear DataBinding
Me.lblCustJob.DataBindings.Clear()
Me.lblCust.DataBindings.Clear()
Me.lblJobDesc.DataBindings.Clear()
Me.lblProjNum.DataBindings.Clear()
Me.lblStateNum.DataBindings.Clear()
Me.lblCompDate.DataBindings.Clear()
Me.ckbActive.DataBindings.Clear()
Me.ckbMMM.DataBindings.Clear()
' Add DataBinding
Me.lblCustJob.DataBindings.Add("Text", mhsJobDT, "custJob")
Me.lblCust.DataBindings.Add("Text", mhsJobDT, "cust")
Me.lblJobDesc.DataBindings.Add("Text", mhsJobDT, "jobDesc")
Me.lblProjNum.DataBindings.Add("Text", mhsJobDT, "projNum")
Me.lblStateNum.DataBindings.Add("Text", mhsJobDT, "stateNum")
' Format Date
Me.lblCompDate.DataBindings.Add("Text", mhsJobDT, "compDate", True).FormatString = "MM/dd/yyyy"
Me.ckbActive.DataBindings.Add("Checked", mhsJobDT, "Active")
Me.ckbMMM.DataBindings.Add("Checked", mhsJobDT, "MMMDisc")
' Testing
Me.tsbCmbMHSJob.DroppedDown = True
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
|