显示带有控件标题的消息框 [英] Display messagebox with control's caption
本文介绍了显示带有控件标题的消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们,我正在运行时创建一些控件,当用户单击该控件时,我想使用MsgBox
显示控件的标题.
Hi folks, I am creating some controls at runtime and when the user clicks that control, I want to use MsgBox
to display the control''s caption.
推荐答案
处理Click
事件,传递给事件处理程序的sender
参数将成为源控件.使用MsgBox
显示该Control
的Text
属性.
Handle theClick
event, thesender
argument passed to the event handler will be the source control. UseMsgBox
to display theText
property of thatControl
.
这是按钮单击事件处理程序的一种解决方案(在C#中).只需使用您自己的控件的click事件处理程序即可.
Hi, here is one solution (in C#) for a button click event handler. Just use the click event handler of your own control.
private void btn_click(object sender, EventArgs e)
{
Button button = sender as Button;
if(button != null)
{
MessageBox.Show(button.Text);
}
}
这篇关于显示带有控件标题的消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文