Home > Net > C # winform how to change the button color
C # winform how to change the button color
Time:11-08
The color of the is click after the change, how to implement
CodePudding user response:
//set the background color of the button Button. UseVisualStyleBackColor=false Button. The BackColor=System. Drawing. Color. Red
CodePudding user response:
Using System; Using System. Collections. Generic; Using System.Com ponentModel; Using System. The Data; Using System. Drawing; Using System. The Text; Using System. Windows. Forms; The namespace WindowsApplication1 { Public partial class Form1: Form { Boolean isTrue=true; Public _click () { InitializeComponent (); } Private void button1_Click (object sender, EventArgs e) { If (isTrue) { This. For. Text="online"; This. For. ForeColor=Color. Blue; } The else { This. For. Text="offline"; This. For. ForeColor=Color. Red; } IsTrue=! IsTrue. } } }