Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Inherited ComboBox Control resizes itself(not wanted) in the forms designer when set to DropDownStyle.Simple
 

Inherited ComboBox Control resizes itself(not wanted) in the forms designer when set to DropDownStyle.Simple

I am trying to create a custom combo box that inherits from ComboBox and supports all 3 DropDownStyles, but I keep getting an anomaly in the way the forms designer display my cutom ComboBox when it is set to DropDownStyle.Simple.

When the inherited ComboBox is set to DropDownStyle.Simple the Designer Resizes it improperly to include the DropDown(I think).

The Inherited ComboBox does this before adding any Code other than the Designer generated Code.

To repeat this weird beahvior(I'm Using Visual Studio 2005 Pro)

1. Create a new Windows Form Project

2. Create a new User Control

3. Changes the class definition of the UserControl to Inherit from ComboBox instead of UserControl

4. Comment out the line AutoScaleMode line in the .designer.cs file, likebelow, because the ComboBox doesn't Support the AutoScaleMode property.

5. Build the Project so your control will show in the designer.

6. Swith to View Designer of the Form and Drop the new user control into the form from the Toolbox

7. Change the DropDownStyle of the new UserControl to Simple and BAM unwanted resizing.

//this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

Any help is greatly appreciated!

m_shane_tx  Friday, November 10, 2006 8:46 PM
I've found the same thing. Anyone got any ideas?
jameshg  Tuesday, September 15, 2009 10:41 AM
I have tested your scenario and I think I know what you mean. A somewhat square box is added just below the "original box". It is the window that displays the Items colleciton. You can verify this by adding items to the Items collection in design-time.

I understand that you call this as undesirable, but the stock, Microsoft-provided combobox does the exact same thing, and you ARE inheriting from it. So I am unsure about what you complain about. The behavior is expected unless you override it.
MCP
  • Proposed As Answer bywebJose Wednesday, September 23, 2009 4:50 AM
  •  
webJose  Tuesday, September 15, 2009 7:29 PM

You can use google to search for other answers

Custom Search

More Threads

• In VS2005, the Visual Designer keeps rearranging the order and position of Toolstrips.
• Refreshing a UserControl
• Multiline Attribute used in TextBox.Text property
• MainMenu designer
• Global Right Mouse Click at Design Time
• DesignTime licensing in a PopUp form which runs via verbs
• My Control's Are Stacked!
• Common practice on capturing the click event on MDI application?
• add a form to a panel
• Loading class methods in a property dropdown