473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Drop down a combobox programatically ?

Hi,

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

Thanks
Sep 17 '06 #1
7 26169
hung tran wrote:
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#)
------------------------------------------------------------------------
Sep 18 '06 #2
On Mon, 18 Sep 2006 00:57:18 -0700, "Frans Bouma [C# MVP]"
<pe******************@xs4all.nlwrote:
hung tran wrote:
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
Sep 18 '06 #3
On Mon, 18 Sep 2006 12:07:26 +0200, hung tran <om*****@gmx.netwrote:
>On Mon, 18 Sep 2006 00:57:18 -0700, "Frans Bouma [C# MVP]"
<pe******************@xs4all.nlwrote:
>hung tran wrote:
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
Sep 18 '06 #4
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
Sep 18 '06 #5
You don't need P/Invoke for this. Just set the DroppedDown property to true

/claes

"Nand Kishore Gupta" <Na**************@discussions.microsoft.comwrote in
message news:9C**********************************@microsof t.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);
--
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

Sep 18 '06 #6
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"
<lo*****@nospam.nospamwrote:

:>You don't need P/Invoke for this. Just set the DroppedDown property to true
:>
: /claes
:>
:>"Nand Kishore Gupta" <Na**************@discussions.microsoft.comwrote in
:>message news:9C**********************************@microsof t.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);
:>--
:>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
:>>>
:>
Sep 18 '06 #7
On Tue, 19 Sep 2006 00:50:42 +0200, om*****@gmx.net wrote:
>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.
<Rolls eyes<G>
>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 moreCool! Problem solved.

--
Posted via a free Usenet account from http://www.teranews.com

Sep 18 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andy Bates | last post by:
I've got what at first appears to be a really simple problem. I have a dropdown combobox with a list of names in, the user can enter text into the edit portion or drop the combobox and select a...
3
by: Angel | last post by:
is there a combo box that a user can key something in or select from the drop down list? i added the webcontrol drop down but there is no property to allow the user to key into the text portion of...
3
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box...
3
by: excel_hari | last post by:
Hi, I couldnt locate a Classic ASP group hence posting here. One of my colleagues has designed an intranet site and one of the pages has a drop-down box with close to 300 options. I want to...
17
by: Aussie Rules | last post by:
Hi, I want to have a single line combo box dropdown, but where i can selected multiple items in the drop down via a check box... I can see one in the standard tool box... is there one ? If...
0
by: TD | last post by:
I have a combobox that is sometimes slow to drop down when clicked on. If you select an item in the list that is near the top of the list then the next time you click on the combobox it drops down...
6
by: zacks | last post by:
I have an application I am developing that has a Combo Box that is intended to show a list of available tables in the selected DSN. I have put code in the control's DropDown event handler to clear...
3
by: - HAL9000 | last post by:
I am trying to get an event when the drop-down Combo Box goes away / reverts back to showing a single item. For example, clicking the box's down arrow, to remove the drop-down window, doesn't...
3
by: jcassan | last post by:
Hello folks. I am new to these forums and have something, which has been stumping me for little while. I am using pspell to spellcheck a scrolling textbox (textarea) containing user input. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.