Question

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?

Was it helpful?

Solution

Set the Dock property to Bottom

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top