ComboBox and automatic dropDown

P

Peter Stojkovic

VB 7.1 and windows.forms.

I have a comboBox on a form.
When the user goes with TAB-Key to the comboBox,
the comboBox should dropDown the ListBox automatically
and show ALL entries.
The user has no possibility to use a mouse !!

How can I program a automatic dropDown ( Showing all entries ),
if the user tabs to the comboBox ???


Thanks
for any help
Peter
 
M

Marc Cramer

Hello...
One solution is to write a custom control that inherits from the
combobox and listen for a specific message...
Private Const WM_SETFOCUS As Int32 = &H7

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
Select Case m.Msg
Case WM_SETFOCUS
Me.DroppedDown = True
Case Else
' do nothing...
End Select
End Sub

Also maybe
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As Short
and check to see if the tab was down...? if so set droppeddown = true

Hope this helps...

Marc Cramer
 
S

Shiva

Another option: Have SendKeys.Send ("{F4}") on the GotFocus event of the
dropdown.

VB 7.1 and windows.forms.

I have a comboBox on a form.
When the user goes with TAB-Key to the comboBox,
the comboBox should dropDown the ListBox automatically
and show ALL entries.
The user has no possibility to use a mouse !!

How can I program a automatic dropDown ( Showing all entries ),
if the user tabs to the comboBox ???


Thanks
for any help
Peter
 
S

Shiva

Yet another option: Have ComboBox.DroppedDown = True in the GotFocus event
of that combo box.

VB 7.1 and windows.forms.

I have a comboBox on a form.
When the user goes with TAB-Key to the comboBox,
the comboBox should dropDown the ListBox automatically
and show ALL entries.
The user has no possibility to use a mouse !!

How can I program a automatic dropDown ( Showing all entries ),
if the user tabs to the comboBox ???


Thanks
for any help
Peter
 
C

Cor Ligthert

Peter,

Very quick and dirty
\\\
Private Sub ComboBox1_Enter(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles ComboBox1.Enter
ComboBox1.DropDownStyle = ComboBoxStyle.Simple
Me.ComboBox1.Size = New System.Drawing.Size(160, 152)
'size as you wish
End Sub
Private Sub ComboBox1_Leave(ByVal sender As Object, ByVal e _
As System.EventArgs) Handles ComboBox1.Leave
ComboBox1.DropDownStyle = ComboBoxStyle.DropDown
Me.TextBox1.Focus() 'Next control or a nicer way
End Sub
///
I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

Peter Stojkovic said:
How can I program a automatic dropDown ( Showing all entries ),
if the user tabs to the comboBox ???

Add a handler to the control's 'Enter' event and set its 'DroppedDown'
property to 'True' there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top