combo box dropdown via code?

  • Thread starter Thread starter Paul
  • Start date Start date
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
 
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
 
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!!!
 
Back
Top