1

there! I am creating a Notepad-Like program (much more advanced) and there is something bothering me...

Notepad++ & Notepad have the Status Bar located just under the RichTextBox/TextBox border. LITERALLY RIGHT UNDER IT.

I put a Status Bar onto my form, and added the controls (Lines, Line, Column, FileSize...) but I still cannot get it to stay under the RichTextBox, so that it will not block the user's view of text.

For EXAMPLE...

I have a RichTextBox, and a user loads a huge file into it. They scroll down to the very bottom, and the last one or two lines are covered by the Status Bar.

I want it to stay below the RichTextBox, so that it doesn't block the user's view. It seems sloppy and will cause my customers to demand refunds.

1
  • i.ibb.co/jz84jBx/Capture.png - That's my layout. As you can see, the statusbar is covering the last one or two lines of the richtextbox. :( Commented Oct 20, 2019 at 2:45

1 Answer 1

4

When docking controls inside a container, the priority of a docked control over another is regulated using their z-order. A Control with a higher priority (a lower position in the z-order) takes precedence in the layout over controls with a lower priority (a higher position in the z-order).

Controls' Docking Priority

See also the Remarks section of the Control.Dock Property.

To assign the a higher priority, right-click on a docked Control and select SendToBack.
A lower priority is assigned selecting BringToFront instead.

In this specific case, an undocked RichTextBox was obscured by a StatusBar control (not a StatusStrip, there's a little diffference on how the z-order is assigned to these 2 controls), which is docked to Bottom as default.
A solution is to dock the RichTextBox control, give it a lower priority by right-clicking it and selecting BringToFront.
Repeat the operation on the StatusBar control, selecting in this case SendToBack. This will cause the StatusBar to take the whole bottom part of its Form container, while the RichTextBox control occupies the space left.
The two controls don't overlap anymore and the layout is not compromised when the Form is resized.

Sign up to request clarification or add additional context in comments.

2 Comments

Marked as Answer! - Though... It is kind of weird.. How you can bring it to front, and have it sent to back...? Or is it a trick of the eye...? Heh... :D
Read again the first part: when you SendToBack a control, you assign to it a lower z-order. Controls with a lower z-order have a higher priority over other controls in the same stack. It may seem counter-intuitive at first, considering you have (apparently) a different behavior when controls are not docked. Just consider how this setting changes the z-order of controls and how this is interpreted in each context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.