Reputation: 8025
I tried set that, but when this, my Form still have greater height. Is any way to do this?
Upvotes: 1
Views: 342
Reputation: 1165
Here is a solution that works for me.
In your class derived from Form, override two methods to bypass the size correction that is applied and that forbid you to set sizes below the limitation.
// the *real* width and height of your form, Width and Height are now lying...
internal int CoreWidth { get; private set; }
internal int CoreHeight { get; private set; }
// just for fun :
public new int Width { get { return CoreWidth; } }
public new int Height { get { return CoreHeight; } }
protected override void SetClientSizeCore ( int x, int y )
{
// get wished width and height earlier enough in the chain of calls
CoreWidth = x;
CoreHeight = y;
base.SetClientSizeCore ( x, y );
}
protected override void SetBoundsCore ( int x, int y, int width, int height, BoundsSpecified specified )
{
// don't trust width and height that are provided, use the ones you kept
base.SetBoundsCore ( x, y, CoreWidth, CoreHeight, specified );
}
Worked like a charm... I using that to create some kind of notification windows that pop anywhere on the screen, that can contains any kind of control and have any size, with no limitation.
Upvotes: 1
Reputation: 2760
Make ControlBox=False; and you will get what you want. Because it is ControlBox have size more than 30x30, without it you can do all size.
Upvotes: 1
Reputation: 8187
With the Sizable style, it is impossible to resize the window below a certain minimum value, even if you have set ControlBox to false and assigned a zero-length string to Text. Consider working around this by using the
SizableToolWindow style
instead.
Upvotes: 2
Reputation: 5123
I can only assume that the problom is the border style all forms have a border the you cant change if you dont mind having no border just set the border style to none and then the form height can be even 0px
Upvotes: 1
Reputation: 94625
May be you have set true
to Form.AutoSize
property. Turn off the AutoSize=false
.
Upvotes: 1