How can I keep a Status Bar from covering my RichTextBox…? C#

邮差的信 提交于 2021-01-20 09:35:10

问题


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 IMMEDIATELY!

HELP IS APPRECIATED! :)


回答1:


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).

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.



来源:https://stackoverflow.com/questions/58460651/how-can-i-keep-a-status-bar-from-covering-my-richtextbox-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!