【代码块】-CS-控件属性和时间

发布时间 2023-08-08 22:52:02作者: 叫夏洛啊

整理代码块

代码块整理后存储,供后期使用

// winForm,根据控件的名字获取控件
Control control = Controls.Find("button1", true)[0];

// 获取属性
object o = control.GetType().GetProperty("PropertyName").GetValue(control, null);

// 获取事件
System.Reflection.EventInfo ev = control.GetType().GetEvent("Click");

// 自定义控件 的自定义方法, 显示到控件事件栏 自定义事件
public delegate void XxxEventHandler(object sender,XxxEventArges e);
public event XxxEventHandler Xxx; // 显示到控件事件栏
protected virtual void OnXxx(XxxEventArges e){
  if(Xxx != null)
     Xxx(this,e);
}