我寫了下面的代碼來改變標籤的邊框顏色,但它不起作用。這與我在標籤屬性中給出的相同。標籤和麪板邊框顏色不起作用
void label1_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, label1.DisplayRectangle, Color.Red, ButtonBorderStyle.Solid);
}
我發現此代碼here。
我寫了下面的代碼來改變標籤的邊框顏色,但它不起作用。這與我在標籤屬性中給出的相同。標籤和麪板邊框顏色不起作用
void label1_Paint(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, label1.DisplayRectangle, Color.Red, ButtonBorderStyle.Solid);
}
我發現此代碼here。
我試過你的代碼,它工作正常。所以我想問題是你沒有訂閱你的標籤Paint
事件。所以,你必須做的這兩個選項之一:
選擇標籤屬性,進入事件,雙擊Paint
事件。
添加到您的窗體的構造函數或Load
事件:
label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint);
您已接受的答案。如果您有新問題,請發佈新問題。用你的代碼正確記錄它。 – LarsTech