有什么办法可以改变标签的模式,即。而不是全红色让我说我想要背景颜色是红色并且它必须有垂直线/水平线等)
请您参考如下方法:
您可以创建继承自 Label 的 Label 控件并覆盖 OnPaintBackground
class MyLabel: System.Windows.Forms.Label {
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent) {
HatchBrush brush = new HatchBrush(HatchStyle.Cross, Color.Red, Color.White);
pevent.Graphics.FillRectangle(brush, ClientRectangle);
}
}
