WinForm控件之【Button】
阅读原文时间:2023年07月16日阅读:4

基本介绍

普通按钮大部分情况下用作页面对某系列操作后的提交确认,应用较为广泛,在winfrom控件当中使用设置都相对的简单。

常设置属性、事件

Image:控件上显示的图片;

Enabled  :指示是否启用该控件,true为启用状态用户可单击控件触发事件,false为禁用状态呈现浅灰状态用户无法单击控件触发事件;

Name:指示代码中用来标识该对象的名称;

Text:与控件关联的文本,显示给用户看的内容说明;

Click事件:单击组件时发生;

事例举例

private void button1_Click(object sender, EventArgs e)
{
if (this.button2.BackColor == SystemColors.Control)
{
this.button2.BackColor = Color.Transparent;
this.button2.FlatStyle = FlatStyle.Flat;
this.button2.FlatAppearance.BorderSize = ;
this.button2.FlatAppearance.MouseOverBackColor = Color.Transparent;
this.button2.FlatAppearance.MouseDownBackColor = Color.Transparent;
this.button2.UseVisualStyleBackColor = false;
}
else
{
this.button2.BackColor = SystemColors.Control;
this.button2.FlatStyle = FlatStyle.Standard;
this.button2.FlatAppearance.BorderSize = ;
this.button2.FlatAppearance.MouseOverBackColor = Color.Empty;
this.button2.FlatAppearance.MouseDownBackColor = Color.Empty;
this.button2.UseVisualStyleBackColor = true;
}
}

控件属性功能相当齐全,精心设置花样会很多,具体看官们可自行研究,在此不再一一例举!

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章