Right-aligned labels in WinForms

后端 未结 9 1528
甜味超标
甜味超标 2021-01-07 15:59

The most obvious way to right-align a Label in WinForms doesn\'t work: setting anchor to Top/Bottom Right and TextAlign to TopRight. If the text changes the lab

9条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 16:39

    One simple option is to disable AutoSize (set to false) and over-size it so there is spare space.

    Alternatively, perhaps use Dock instead of just Anchor, although this has a different meaning, so you may need to put it in a Panel or similar). Ultimately this works like the first - by over-sizing it in the first place; so perhaps the first option is simpler.

提交回复
热议问题