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.
}
}
}

CodePudding user response:

reference 1st floor Dear200892 response:
 
//set the background color of the button
Button. UseVisualStyleBackColor=false
Button. The BackColor=System. Drawing. Color. Red

Thank you, useful, just testing

CodePudding user response:

Private void button1_Click (object sender, EventArgs e)
{
For the. BackColor=Color. FromArgb (xue gong cheng xue bao);
}
 

CodePudding user response:

//set the background color of the button
Button. UseVisualStyleBackColor=false
Button. The BackColor=System. Drawing. Color. Red

CodePudding user response:

The floor in front of the can

CodePudding user response:

Generally encountered this problem, you can view each have a look at the button of each attribute, this will help you a lot,

CodePudding user response:

Set in the winform button interface properties

CodePudding user response:

Concrete implementation of the statement is: btn_name BackColor=Color. Red;
Btn1_name. BackColor=Color. Green;

CodePudding user response:

Do Winform can try to use CSkin the UI components, more perfect, simple to use

CodePudding user response:

 button. UseVisualStyleBackColor=false 
Button. The BackColor=System. Drawing. Color. Red

CodePudding user response:

Just looked at all the maintenance

CodePudding user response:

I also learned, thank you

CodePudding user response:

Button. The BackColor=System. Drawing. Color. Red
  •  Tags:  
  • C#
  • Related