Re: Drop down a combobox programatically ?

Tech-Archive recommends: Speed Up your PC by fixing your registry



You don't need P/Invoke for this. Just set the DroppedDown property to true

/claes

"Nand Kishore Gupta" <NandKishoreGupta@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:9CCF9705-22E4-492D-98BF-E0994EEE1E11@xxxxxxxxxxxxxxxx
You can drop the list portion of a combo box programatically using Windows
SendMessage API. To do so in C#:

// Declare the following in your class

[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr
lParam);
public const int CB_SHOWDROPDOWN = 0x14F;

// In the leave event of combobox, use the following code:

SendMessage(comboBox1.Handle.ToInt32(), CB_SHOWDROPDOWN, 1, IntPtr.Zero);
--
Nand Kishore Gupta


"hung tran" wrote:

Hi,

I'd like to drop down a combobox after validating the Leave() event, how
can I do that ?

Thanks



.



Relevant Pages

  • Re: C++ dll in C#
    ... you should declare your parameters as int. ... public static extern int Multiple ... /// Summary description for Class1. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: changing an int value across classes,kind of working :s
    ... base and gui. ... > The int size ... ... the user selects index2 of the comboBox and it changes the ... > yet it just doenst work. ...
    (comp.lang.java.gui)
  • Re: ListItem not available in win forms
    ... You can put anything in a combobox, be it a string, int, float or a custom ... The combobox will call the ToString method of the object to find out ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Sending CB_GETDROPPEDSTATE to a Combobox always returns zero
    ... ComboBox is already opened or not. ... const int CB_GETDROPPEDSTATE = 0x157; ... public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, ... IntPtr tmp = GetCapture; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Sending CB_GETDROPPEDSTATE to a Combobox always returns zero
    ... Since I want a ComboBox to automatically open when the user presses a key I'm using the attached code. ... const int CB_GETDROPPEDSTATE = 0x157; ... public static extern IntPtr SendMessage; ...
    (microsoft.public.dotnet.framework.compactframework)