You can override SetBoundsCore
and make it to use height of ComboBox
as height of your control:
protected override void SetBoundsCore(int x, int y, int width, int height,
BoundsSpecified specified)
{
base.SetBoundsCore(x, y, width, comboBox1.Height, specified);
}
Note 1: If your UserControl
contains just a ComboBox
, it's better to derive from ComboBox
rather than creating a user control containing a ComboBox
Note 2: You can make it obvious in the designer that control can just resized from left or right by creating a new ControlDesigner
and overriding SelectionRules
property. To do so, add a reference to System.Design
assembly and then create a custom designer:
using System.Windows.Forms.Design;
public class MyControlDesigner : ControlDesigner
{
public override SelectionRules SelectionRules
{
get
{
return SelectionRules.LeftSizeable |
SelectionRules.RightSizeable |
SelectionRules.Moveable;
}
}
}
Then it's enough to decorate your custom control with designer attribute this way:
[Designer(typeof(MyControlDesigner))]