Archiv für Mai 2011

Horziontal Rule in WinForms

Sometime you need a horizontal rule in your WinForms dialog, like the HTML <hr> element. In MFC you have done it with a Static and in WinForms you do it with the equivalent to it, the Lable. First you need to empty the Text of the Label and set the BorderStyle to “Fixed3D”. To set a Witdh or Hight you need to set AutoSize to false. Then you set a Height of 2 and a Width of e.g. 100 and see you have a horizontal rule. If you set the Height to 3 or 4, you can also change the BackColor and get a colorfull version of your horizontal rule. The same applies to a vertical rule, you only swap Width and Height.


Hinterlasse einen Kommentar