我得到的C#代码如下:
if(smth == "Open")
{
TextBox.Background = ???
}
Run Code Online (Sandbox Code Playgroud)
如何更改TextBox的背景颜色?
Mar*_*ila 19
如果它是WPF,则静态类中有一组颜色Brushes.
TextBox.Background = Brushes.Red;
Run Code Online (Sandbox Code Playgroud)
当然,如果需要,您可以创建自己的画笔.
LinearGradientBrush myBrush = new LinearGradientBrush();
myBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
myBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
myBrush.GradientStops.Add(new GradientStop(Colors.Red, 1.0));
TextBox.Background = myBrush;
Run Code Online (Sandbox Code Playgroud)
Dim*_*rov 17
在WinForms和WebForms中,您可以:
txtName.BackColor = Color.Aqua;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
107868 次 |
| 最近记录: |