Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I would like to set the DropDownStyle to DropDown in a ComboBox that is in a DataGridView control. I would like to do this by setting this property at design time; however, it isn't an option I can pick. Doing it when the form loads would be fine, but I don't know how to do it (VB.net, please).

Thanks, Eddie
Posted
Updated 22-Jan-11 12:52pm
v2

If your ComboBox is part of a ComboBoxColumn then Manfred's solution might not work.

Take a look at this[^] thread on MSDN.Social (Scroll down until you see the first message from 'mcassoc') and in that message take note of the event handler for the EditingControlShowing event. Using that code to handle that event on your DataGridView will enable you to achieve what you want.
 
Share this answer
 
Comments
Sandeep Mewara 23-Jan-11 3:39am    
Comment from OP:
Henry is right... Manfred's answer won't apply if the ComboBox is part of a ComboBoxColumn. I'm still trying to digest Henry's answer to see if it will work. My background is from VBA. Who would think that a "Limit to List Y/N" would be so powerful? Do you think a later release of VB.net might provide that simple(?) property?

Thanks, Eddie
You can do it from your forms load event or in the forms constructor:
VB
...
Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDown
...


Hope that helps you.

Best Regards,
Manfred
 
Share this answer
 
Comments
Nish Nishant 22-Jan-11 18:56pm    
Voted 5, proposed as answer.
Nish Nishant 22-Jan-11 20:15pm    
After reading Henry's reply, I retract my proposal as answer, but my 5 remains.
Sandeep Mewara 23-Jan-11 3:39am    
Comment from OP:
Henry is right... Manfred's answer won't apply if the ComboBox is part of a ComboBoxColumn. I'm still trying to digest Henry's answer to see if it will work. My background is from VBA. Who would think that a "Limit to List Y/N" would be so powerful? Do you think a later release of VB.net might provide that simple(?) property?

Thanks, Eddie

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900