combo box dropdown via code?

P

Paul

Is there a way to get a dropdown combo box to expand via code? I tried
setting focus but that didnt work.

Thanks
 
P

Peter Foot [MVP]

You can programmatically send the control an F4 keypress (once the control
has focus) which will drop the list. OpenNETCF.Windows.Forms.SendKeys has
functionality to do this - www.opennetcf.org/sdf/

Peter
 
P

Paul

Peter,

Thanks for the help. I tried the following code it didnt work. Are you sure
its F4? Does the kb_event line look right?

Thanks.

private const byte VK_F4 = 0x73;

[DllImport("coredll.dll")]
private static extern void keybd_event(byte bVk, byte bScan, uint
dwFlags, uint dwExtraInfo);

protected void ExpandDropDown(ComboBox cb)
{
cb.Focus();
System.Windows.Forms.Application.DoEvents();

keybd_event(VK_F4, 0, KEYEVENTF_KEYDOWN, 0);
}

Thanks Again!!!
 

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