有什么办法可以改变标签的模式,即。而不是全红色让我说我想要背景颜色是红色并且它必须有垂直线/水平线等)
最佳答案
您可以创建继承自 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);
}
}
关于c# - 如何在c#中更改标签填充模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10242124/