• WinForm控件之【Button】


    基本介绍

    普通按钮大部分情况下用作页面对某系列操作后的提交确认,应用较为广泛,在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 = 0;
                    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 = 1;
                    this.button2.FlatAppearance.MouseOverBackColor = Color.Empty;
                    this.button2.FlatAppearance.MouseDownBackColor = Color.Empty;
                    this.button2.UseVisualStyleBackColor = true;
                }
            }

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

     

  • 相关阅读:
    暑假第五周报告
    读《大道至简》有感
    暑假第四周报告
    暑假第三周报告
    暑假第二周报告
    暑假第一周报告
    对15号夏壹队的TD信息通——teamfinal的使用体验
    Django易混淆问题
    MySQL常见问题
    Django框架的理解和使用的常见问题
  • 原文地址:https://www.cnblogs.com/ljhandsomeblog/p/11125150.html
Copyright © 2020-2023  润新知