I made a custom control and I want to make impossible to resize it.
I follow these steps:
- I use a ControlDesigner (overridden SelectionRules)
- I hide the public Size property and make it readonly
- I override the protected DefaultSize property
and I achieve the correct behaviour in the designer.
The problem is that at runtime the control is many times bigger the size specified in the size property and I don't understand where this wrong size is read.
Does anyone found this problem yet?
Thanks in advance
Instead of hiding and making ReadOnly the Size property, modify the OnResize
method so that your fixed size is restored.
Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.Size = New Size(50, 23)
End Sub
protected override void OnResize(EventArgs e)
{
base.Size = new Size(50, 23);
}

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
> I made a custom control and I want to make impossible to resize it.
> I follow these steps:
[quoted text clipped - 5 lines]
>
> The problem is that at runtime the control is many times bigger the size specified in the size property and I don't understand where this wrong size
is read.
> Does anyone found this problem yet?
>
> Thanks in advance
GG - 30 Jul 2004 10:31 GMT
Thanks Mick but I found another solution: in the constructor of the control I insert
this.Bounds = new Rectangle(this.Location.X, this.Location.Y, this.defaultSize.Width, this.defaultSize.Height);
and now all things works properly.
I forgot to mention that i'm working with compact framework so the defaultSize property is not available.