最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net 生成控件后自动获取控件的name值
时间:2022-06-25 05:35:33 编辑:袖梨 来源:一聚教程网
asp教程.net 生成控件后自动获取控件的name值
//用控件的tag属性比较方便
private void message(object sender,eventargs e)
{
picturebox pic = sender as picturebox;
string lblname=((label)pic.tag).name;
messagebox.show(lblname);
}
//动态生成控件时,指定name,然后找到它:foreach (control ct in form1.controls)
{
//c# 只遍历窗体的子控件,不遍历孙控件
//当窗体上的控件有子控件时,需要用递归的方法遍历,才能全部列出窗体上的控件
if (ct.name=="")
{
}
}
}
//实例
picturebox p = new picturebox();
p.name = "p" + i.tostring();
p.sizemode = system.windows.forms.pictureboxsizemode.stretchimage;
p.imagelocation = @"d:www.111com.nethome4.png";
p.size = new system.drawing.size(60, 60);
p.location = new system.drawing.point(5 * 17 * i-60, 50);
p.cursor = system.windows.forms.cursors.hand;
p.doubleclick += new eventhandler(message);
p.mousemove += new system.windows.forms.mouseeventhandler(this.mouseo教程ver);
p.mouseleave += new system.eventhandler(this.mouseo教程ut);
p.contextmenustrip = contextmenustrip1;
this.sp_l_r.panel2.controls.add(p);
label la = new label();
la.name = "la" + i.tostring();
la.text = "0000";
la.location = new system.drawing.point(50, 120);
this.sp_l_r.panel2.controls.add(la);
相关文章
- 原神5.5深渊12层阵容推荐打法攻略 07-01
- 金铲铲之战s14圣灵塞纳阵容搭配指南 07-01
- JSB Foundation(JSB币)非法传销 07-01
- 原神5.5下半深渊满星打法指南 07-01
- 云顶之弈s14辛迪加卡牌阵容搭配推荐 07-01
- 魔兽世界11.1.5最新头部腐蚀附魔排名一览 07-01