使用 Sender 参数
来源:互联网 发布:11.4恒大淘宝的比赛 编辑:程序博客网 时间:2024/05/01 05:05
In an event handler, the Sender parameter indicates which component received the event and therefore called the handler. Sometimes it is useful to have several components share an event handler that behaves differently depending on which component calls it. You can do this by using the Sender parameter in an if...then...else statement. For example, the following code displays the title of the application in the caption of a dialog box only if the OnClick event was received by Button1.
在一个事件句柄,Sender参数指的是哪一个组件接受该事件并因此调用了该事件。有时当几个组件共用同一事件句柄是很有用的,事件产生不同的行为是由调用它的组件所决定。要做到这点,你只要将Sender参数与if……then……else语句结合使用就可以了。下列代码示范了当button1按钮的OnClick事件发生时将程序的标题显示在指定对话框的标题上。
procedure TMainForm.Button1Click(Sender: TObject);
begin
if Sender = Button1 then
AboutBox.Caption := 'About ' + Application.Title
else
AboutBox.Caption := '';
AboutBox.ShowModal;
end;
- 使用 Sender 参数
- UIButton sender参数
- zabbix sender的使用
- sender
- Sender
- BCB中用Sender参数实现代码重用
- Delphi用Sender参数实现代码重用
- 关于(object sender, System.EventArgs e)中参数sender和e的问题
- 事件处理程序中sender参数的用法
- BCB中用Sender参数实现代码重用(修正版)
- WinForm控件消息处理的两个参数sender和e
- C# 事件函数参数(object sender, EventArgs e)
- DevExpress GridView中RepositoryItem事件参数sender转换为Gridview
- 代理的使用及-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
- 通过Sender实现多个控件使用一个事件
- 使用System.Net.Mail注意区分form和sender
- IOS storyboard之 prepareForSegue:sender:方法的使用
- postfix中限制认证用户使用的sender address
- SQLServer和Access、Excel数据传输简单总结
- Visual C++在异步串行通信控制中的应用
- ANT安装、配置
- 同愚昧作斗争
- JAVA面试题集
- 使用 Sender 参数
- 网络时代计算机病毒发展的新趋势
- 在rational rose的sequence图中表示条件逻辑。
- VC 7.0 中使用CDaoRecordset 类/使用Dao 方法操作数据库
- 今天开始用电驴(e-mule)
- 今天关于研究mysql的sql语句所积累的……
- How To Invoke a Parameterized ADO Query Using VBA/C++/Java
- 打印机十大共性故障的解决方法
- java初学者必读-经验总结