In article <52***********@ DotNetMonster.c om>,
fo***@DotNetMon ster.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(ByV al index As Integer)
MyBase.RefreshI tem(index)
End Sub
' abstract method. just call base class method
Protected Overrides Sub SetItemsCore(By Val items As
System.Collecti ons.IList)
MyBase.SetItems Core(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