for (int i = 0; i < 10; i++)
{
TextBox t = new TextBox();
t.Location = new Point(10 + i * 70, 150);
t.Name = "txttest" + Convert .ToString (i);
t.Size = new Size(60,100);
t.Visible = true;
t.Parent = this;
t.ReadOnly = true;
t.TextAlign = HorizontalAlignment.Center;
t.BringToFront();
t.Text = "0";
}
我使用以上代码生成10个TextBox后,需要使用定时器隔一段时间更新一次所有TextBox的内容。请问如何实现?
{
TextBox t = new TextBox();
t.Location = new Point(10 + i * 70, 150);
t.Name = "txttest" + Convert .ToString (i);
t.Size = new Size(60,100);
t.Visible = true;
t.Parent = this;
t.ReadOnly = true;
t.TextAlign = HorizontalAlignment.Center;
t.BringToFront();
t.Text = "0";
}
我使用以上代码生成10个TextBox后,需要使用定时器隔一段时间更新一次所有TextBox的内容。请问如何实现?
解决方案 »
- C#在VS2010里面怎么操作Mongodb
- dataset中多个datatable写到excel中的多个sheet
- 谁给点软件开发思想!
- 请教高手,我想实现一个从Object类派生出的类,能够实现简单数据绑定, 然后实现一个集合类做复杂数据绑定,不知道该怎么实现
- 急急急急,求高手!!!!!
- 一个小问题,关于ExecuteNonQuery()的
- C# 如何实现背景图片全屏显示
- ~~~~~如何设置winfrom DataGrid中Head的值~~~~~
- 如何取得系统的年份。
- 如何在内嵌的类中使用上层类的变量?
- 验证码识别:哪位网友指导我完成这个验证码识别过程,酬谢200元
- 大家看下这个更新语句对吗?
从工具箱拖一个Timer控件到界面,设置Interval属性,即你说的“一段时间”;然后双击Timer控件,VS会自动生成OnTimer事件的处理方法,在该方法中进行更新即可。。
TextBox[] tbs=new TextBox[10]修改你的循环算法:
for (int i = 0; i < 10; i++)
{
TextBox t = new TextBox();
t.Location = new Point(10 + i * 70, 150);
t.Name = "txttest" + Convert .ToString (i);
t.Size = new Size(60,100);
t.Visible = true;
t.Parent = this;
t.ReadOnly = true;
t.TextAlign = HorizontalAlignment.Center;
t.BringToFront();
t.Text = "0";
tbs[i]=t;
} 在Timer控件的Tick事件中处理各TextBoxfor(int i=0;i<10;i++)
{
tbs[i]="刷新的内容"
}