.net 在winforms中绘制水平分隔线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3296110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:32:36  来源:igfitidea点击:

Draw horizontal divider in winforms

.netwinforms

提问by Nathan

In the standard windows installer there is a divider between the control buttons on the bottom and the main part of the form. Does anyone know how this would be done in winforms/.net? I've tried fiddling around with the border settings on Panel controls etc, but haven't been able to get the same result...

在标准的 Windows 安装程序中,底部的控制按钮和窗体的主要部分之间有一个分隔线。有谁知道这将如何在 winforms/.net 中完成?我试过摆弄面板控件等上的边框设置,但无法获得相同的结果......

alt text

替代文字

回答by David Anderson

I used Spy++ to figure this out a while ago and discovered that it's just a standard Win32 Static control -- the equivalent of the WinForms Label. Steps for getting the same effect:

不久前我使用 Spy++ 解决了这个问题,发现它只是一个标准的 Win32 静态控件——相当于 WinForms 标签。获得相同效果的步骤:

  1. Add a Label control to your form.
  2. Set Label Text to empty.
  3. Set BorderStyle to Fixed3D.
  4. Set AutoSize to false.
  5. Set Height to 2 (most easily accomplished by typing 2 into the Size/Height field under Label Properties).
  1. 向窗体添加一个 Label 控件。
  2. 将标签文本设置为空。
  3. 将 BorderStyle 设置为 Fixed3D。
  4. 将 AutoSize 设置为 false。
  5. 将高度设置为 2(通过在标签属性下的大小/高度字段中键入 2 最容易实现)。