111,131
社区成员
发帖
与我相关
我的任务
分享button.UseVisualStyleBackColor=false
button.BackColor = System.Drawing.Color.Red
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
Boolean isTrue = true;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if(isTrue)
{
this.button1.Text = "在线";
this.button1.ForeColor = Color.Blue;
}
else
{
this.button1.Text = "离线";
this.button1.ForeColor = Color.Red;
}
isTrue = !isTrue;
}
}
}
//设置button的背景颜色
button.UseVisualStyleBackColor=false
button.BackColor = System.Drawing.Color.Red