Right-aligned labels in WinForms

后端 未结 9 1502
甜味超标
甜味超标 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:51

    Using a FlowLayoutPanel to do it works very well.

    flowLayoutPanel.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
    flowLayoutPanel2.Controls.Add(label);
    

    Then, just make sure that the flowLayoutPanel is large enough for the label to expand.

提交回复
热议问题