Hi Benico26,
The maximumsize and the minimumsize properties defines the size constraints of the control. The .net layout engine uses this information to layout the controls.
You can change the behaviour of this by overriding the GetPreferredSize method. The GetPreferredSize method is part of the controls class which is inherited by the textbox class.
Here is a little example, which shows how the maximumsize property affects the layout of your controls.
This is the custom control class which inherits the textbox class and uses the maximumsize property:
Code Block
[ToolboxBitmap(typeof(TextBox))]
public class CustTextBox : TextBox
{
public CustTextBox()
{
this.MaximumSize = new Size(40, 30);
}
}
To see it in action, create a new form and add a flowlayoutpanel to it. Now add the custom control to it and you'll see that the size of the textbox is not larger then what you defined, Now change the maximumsize of your control. And add the control again to the flowlayoutpanel. The added textbox will follow the maximumsize constraints.
MSDN:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.getpreferredsize.aspx More info about preferredsize
http://blogs.msdn.com/jfoscoding/articles/478300.aspx Layoutengine class
http://msdn2.microsoft.com/en-us/library/system.windows.forms.layout.layoutengine(VS.90).aspx