• Button.PerformClick()


    Button.PerformClick()

    Button.PerformClick()和button.click()事件是

    1、button.PerformClick()和button_Click(sender,e)的功能:

       两者都是实现单击button控件功能。

    2、两者存在的一点小差异

    实例:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Windows.Forms;
     9 namespace SuperPlane
    10 {
    11     public partial class Form1 : Form
    12     {
    13         public Form1()
    14         {
    15             InitializeComponent();
    16         }
    17         private void button1_Click(object sender, EventArgs e)
    18         {
    19             MessageBox.Show("button1");//弹出窗口
    20         }
    21         private void button2_Click(object sender, EventArgs e)
    22         {
    23             //无论button1.Enabled为true还是为false都会弹出窗口
    24             button1_Click(sender, e);//以button.Click(sender,e)调用button1.Click方法
    25         }
    26         private void button3_Click(object sender, EventArgs e)
    27         {
    28             //只有当button1.Enabled为true时才会弹出窗口
    29             button1.PerformClick();//以button1.PerformClick()模拟button1单击事件
    30         }
    31         private void button4_Click(object sender, EventArgs e)
    32         {
    33             button1.Enabled = !button1.Enabled;//改变button1的Enabled改变
    34         }
    35     }
    36 }
  • 相关阅读:
    组件之间通信(父传子)
    flex布局
    ffmpeg解析TS流(转)
    swift之?和!的含义(转)
    Swift之画圆角添加多个枚举值方法
    swift之singleton
    swift之闭包
    Swift之fallthrough
    Selector
    Settings Bundle
  • 原文地址:https://www.cnblogs.com/pyffcwj/p/3069461.html
Copyright © 2020-2023  润新知