获取面板名称 [英] get panel name
本文介绍了获取面板名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行时生成3个面板.我需要在运行时单击特定的面板名称.我该怎么做?
I am generating 3 panels at runtime. i need to get the specific panel name at runtime which i have clicked. how can i do this?
推荐答案
Click事件具有属性发送者"
The Click event has a property "sender"
private void panel_Click(object sender, EventArgs e)
如果将其投射到面板上,则它是用户单击的面板:
If you cast it to a Panel, then it is the panel the user clicked on:
Panel p = sender as Panel;
if (p != null)
{
...
}
尝试一下.
Try this .
//Use the sender parameter of the event
private void pnl_Click(object sender, EventArgs e) {
Panel panel = (sender as Panel);
//This is the panel. }
这篇关于获取面板名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文