您的位置:首页 > 编程语言 > C#

C#外部控件调用click事件

2017-10-31 17:08 190 查看

控件A定义

自定义控件中有如下click事件:

public event EventHandler Click;


自己调用click

public void DoClick()
{
if (this.Click != null)
{
this.Click(this, new EventArgs());
}
}


外部control定义

在control中有个A控件属性

private NavBarButton _button;


定义该事件:

this._button.Click += new EventHandler
(
delegate(object sender, EventArgs e)
{
if (this._groupState == NavGroupState.collapse)
this.GroupState = NavGroupState.expand;
else
this.GroupState = NavGroupState.collapse;
});


调用事件

this._button.DoClick();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: