Reputation: 23123
My intent is that the form be sized large enough to show the entire "buttonOK", but not much larger. What actually happens is that the resized form ends up to small to even show the button at all.
public MyFormDlg()
{
InitializeComponent();
this.Height = this.buttonOK.Bounds.Bottom + SomePadding;
Upvotes: 3
Views: 227
Reputation: 28050
The Height
property includes the height of the Window's Title bar, thus the client area (the one the button bounds are relative to) is smaller than you expect.
This works:
this.ClientSize = new Size(this.ClientSize.Width,
this.buttonOK.Bounds.Bottom + SomePadding);
I didn't find a ClientHeight
property, can this be done any simpler?
Upvotes: 6