tags:

views:

91

answers:

2

I want to create a custom control (derived from Control class), and when I drag this custom control to a form in designer, I can only change its width. This feature is same as single-line textbox. Please help me. Thanks.

Update: My application is Windows Form.

+1  A: 

Try this

protected override void SetBoundsCore(int x, int y, 
   int width, int height, BoundsSpecified specified)
{
   // Set a fixed height for the control.
   base.SetBoundsCore(x, y, width, 75, specified);
}

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.setboundscore(VS.71).aspx

Veer
+1, this worked great for me!
Brad
A: 
    this.MaximumSize = new System.Drawing.Size(0, 20);
    this.MinimumSize = new System.Drawing.Size(0, 20);

Apparently .NET assumes a minimum and maximum width of 0 to be "any width".

deltreme