最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net 生成控件后自动获取控件的name值
时间:2010-06-21 编辑:简简单单 来源:一聚教程网
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);
-
上一个: asp.net数据绑定与动态改变值的代码
-
下一个: asp.net用户注册程序
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10