By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 2,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

pull down combobpx

P: n/a
Hi All:

How can I activate the spacebar to pull down the combobox?

For instance, once the tab stopped at the combobox, suppose i can use dnarrow
or F4 to pull down the combobox to make selection, but instead of these 2
keys, I want to use spacebar, can I do that?

Best rgds,
Ivan Vong
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"Ivan V via DotNetMonster.com" <fo***@DotNetMonster.com> schrieb:
How can I activate the spacebar to pull down the combobox?


Set the control's 'DroppedDown' property to 'True'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2

P: n/a
In article <52***********@DotNetMonster.com>, fo***@DotNetMonster.com
says...
Hi All:

How can I activate the spacebar to pull down the combobox?

For instance, once the tab stopped at the combobox, suppose i can use dnarrow
or F4 to pull down the combobox to make selection, but instead of these 2
keys, I want to use spacebar, can I do that?


I would subclass the regular combobox and handle the OnKeyDown method:

Public Class MyComboBox
Inherits ComboBox

' abstract method. just call base class method
Protected Overrides Sub RefreshItem(ByVal index As Integer)
MyBase.RefreshItem(index)
End Sub

' abstract method. just call base class method
Protected Overrides Sub SetItemsCore(ByVal items As
System.Collections.IList)
MyBase.SetItemsCore(items)
End Sub

Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
If e.KeyCode = Keys.Space Then
Me.DroppedDown = Not Me.DroppedDown
e.Handled = True
End If
End Sub
End Class

All this does is that when the space key is pressed, it will toggle the
dropdown to either on or off.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 21 '05 #3

P: n/a
i did try, but it's not working!!!
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #4

P: n/a
both method is not working!
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #5

P: n/a
In article <52***********@DotNetMonster.com>, fo***@DotNetMonster.com
says...
both method is not working!


The code was copied directly out of a working project. Could you give
more detail as to what "is not working" means? Are you getting errors?
Can you provide some sample code?

This is a winform app, correct?

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 21 '05 #6

P: n/a
Yes, it's a vb.net application. I just simply add the code that you provided
to me. My comob box named Type, and nothing had changed when the code has
been added!!!
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #7

P: n/a
In article <52***********@DotNetMonster.com>, fo***@DotNetMonster.com
says...
Yes, it's a vb.net application. I just simply add the code that you provided
to me. My comob box named Type, and nothing had changed when the code has
been added!!!


You also need to change the VS.NET generated code. Right now it's
creating a standard System.Windows.Forms.ComboBox. You'd need to change
that to "MyComboBox" (if you use the sample code I provided).

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 21 '05 #8

P: n/a
Thanks Patrick, it works great for me now. How about to activate the up arrow
and down arrow in our keyboard in a window from as the function of tab key?
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #9

P: n/a
In article <52***********@DotNetMonster.com>, fo***@DotNetMonster.com
says...
Thanks Patrick, it works great for me now. How about to activate the up arrow
and down arrow in our keyboard in a window from as the function of tab key?


I'm not sure what you're asking. Do you want the up/down arrow keys to
allow you to move focus around the form like TAB and SHIFT+TAB? Or do
you want the TAB and SHIFT+TAB keys to act like the up/down arrow keys?

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 21 '05 #10

P: n/a
It's the former one which the up/down arrow keys allow me to move focus
around like the TAB and SHIFT + TAB.
Thanks for your attention!
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.