Drop down a combobox programatically ?

  • Thread starter Thread starter hung tran
  • Start date Start date
H

hung tran

Hi,

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

Thanks
 
hung said:
Hi,

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

Why would you want to do that? A combobox standard behavior in windows
is that when you click the [v] button, it will show a list, and when
you leave the control the list will dissapear, which is logical as the
focus is on another control.

Frans

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
hung said:
Hi,

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

Why would you want to do that? A combobox standard behavior in windows
is that when you click the [v] button, it will show a list, and when
you leave the control the list will dissapear, which is logical as the
focus is on another control.

Frans


Hi Frans,

For example the combobox is used for searching customer number (string), if
I enter in the text field "0005" and click the drop down arrow it will
display a list of "00051, 00052, 00053, 00054", I can select one of them.

If I enter "00053" and press tab, it's ok too because the customer 00053
does exist ...

But if I enter "0005" and press tab, there is no customer number 0005 so I
want to display the list automatically as if I click the drop down arrow
....

Actually I don't want this behavior, but our client wants it so -:)

Thanks
 
hung said:
Hi,

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

Why would you want to do that? A combobox standard behavior in windows
is that when you click the [v] button, it will show a list, and when
you leave the control the list will dissapear, which is logical as the
focus is on another control.

Frans


Hi Frans,

For example the combobox is used for searching customer number (string), if
I enter in the text field "0005" and click the drop down arrow it will
display a list of "00051, 00052, 00053, 00054", I can select one of them.

If I enter "00053" and press tab, it's ok too because the customer 00053
does exist ...

But if I enter "0005" and press tab, there is no customer number 0005 so I
want to display the list automatically as if I click the drop down arrow
...

Actually I don't want this behavior, but our client wants it so -:)

Thanks

Then display it as a ComboBoxStyle.Simple so the list is always visible.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
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);
 
You don't need P/Invoke for this. Just set the DroppedDown property to true

/claes

Nand Kishore Gupta said:
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 said:
Hi,

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

Thanks
 
Oh, sorry, I forgot to mention it's an Infragistics UltraCombo
control, I thought it's almost the same as MS combobox but it does not
have DroppedDown property and SendMessage didn't work too.

But I found out it has a method ToggleDropDown(), in the Leave event I
have to focus on other control first then call ToggleDropDown(), work
ok now ...

Thank you all for your help.

Tran

On Mon, 18 Sep 2006 16:29:52 -0400, "Claes Bergefall"

:>You don't need P/Invoke for this. Just set the DroppedDown property to true
:>
:> /claes
:>
:>message :>> 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
:>>>
:>
 
Oh, sorry, I forgot to mention it's an Infragistics UltraCombo
control, I thought it's almost the same as MS combobox but it does not
have DroppedDown property and SendMessage didn't work too.

But I found out it has a method ToggleDropDown(), in the Leave event I
have to focus on other control first then call ToggleDropDown(), work
ok now ...

<Rolls eyes even more> Cool! Problem solved.
 

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

Back
Top