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

Autoexpand a combo box

jamesd0142
100+
P: 469
comboboxname = cboln03

Is it possible to click a button and the combo box expand as if a user clicked the arrow?

so click a button - cboln03 opens to reveal list of items.

Thanks
Dec 18 '07 #1
Share this Question
Share on Google+
6 Replies


Expert 5K+
P: 8,434
You could try this (little sample I just wrote and tested - it appears to work)
Expand|Select|Wrap|Line Numbers
  1. Combo1.SetFocus
  2. SendKeys "{F4}"
Dec 19 '07 #2

lotus18
100+
P: 866
You could try this (little sample I just wrote and tested - it appears to work)
Expand|Select|Wrap|Line Numbers
  1. Combo1.SetFocus
  2. SendKeys "{F4}"
Hi Killer42

Can you explain to us what's the function of using F4? I really have no idea. LOL
Dec 19 '07 #3

Expert 5K+
P: 8,434
When the focus is on a combobox, you can press the F4 key (also Alt-Down, I think) to expand the list.
Dec 19 '07 #4

jamesd0142
100+
P: 469
You could try this (little sample I just wrote and tested - it appears to work)
Expand|Select|Wrap|Line Numbers
  1. Combo1.SetFocus
  2. SendKeys "{F4}"
Thanks thats what i needed!

could you use this sendkeys thingy to capture key press?

say something like:
Expand|Select|Wrap|Line Numbers
  1. if sendkeys.send("{alt+a}") = true then
  2. 'do something
  3. end if
  4.  
Dec 19 '07 #5

Expert 5K+
P: 8,434
I'm not familiar with the capabilities of VB.Net (I use the ten-year-old VB6) but as far as I know SendKeys is only for sending, not receiving.
Dec 19 '07 #6

P: 24
SendKeys does not allow for the processing of keys inputted, however it is possible to detect keyboard actions using keydown/keypress events on different objects. The example below demonstrates how.

Expand|Select|Wrap|Line Numbers
  1. Private Sub textBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs)  Handles textBox1.KeyDown
  2.  
  3. If e.KeyCode == 65 Then
  4.   ' Whatever you wish to do, note you can convert the key code to its ASCII char
  5. End If
  6.  
  7. End Sub
I hope this helps you with getting key input. Each character has its own decimal value and I'm not sure but I believe you can use Chr() to convert its decimal value into the ASCII character.

Chris
Dec 19 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.