David
David

Reputation: 2190

Positioning a StatusStrip on the bottom of a window in Windows Forms

I'm trying to keep a status bar flush up against the bottom left corner of a realizable window without overflowing. I've got it to stay in place by having a resize function that updates the location and size of the status strip, but the bottom and the right side of it are always extending past the window. Here's how I'm calculating where it should go.

statusBar.Location = new System.Drawing.Point(0, Form.Size.Height - 22);
statusBar.Size = new System.Drawing.Size(Form.Size.Width, 22);

Where 22 is the constant height I want the statusBar to be. I know there has to be some other variable I'm not taking into account in setting this that's stored in the form, but I'm not sure how to access it, or what it even is.

What am I doing wrong? And is there any other easier way to keep the statusstrip on the bottom of the window regardless of resize events?

Upvotes: 0

Views: 2738

Answers (2)

ispiro
ispiro

Reputation: 27683

You have to use ClientSize instead of Size.

The following:

textBox1.AppendText(Size.ToString() + "\r\n");
textBox1.AppendText(ClientSize.ToString() + "\r\n");

yields:

{Width=300, Height=300}
{Width=284, Height=262}

Though, of course, it's easiest to just use Boo's answer.

Upvotes: 0

Sam Axe
Sam Axe

Reputation: 33738

Set the Dock property to Bottom

Upvotes: 2

Related Questions