有人能调整下么 代码如连接
想要的是这种:
通过 Button控件 创建5个textbox控件同时也创建5个timer控件
第二个控件控制timer运行
timer控件的事件 比如
timer1为textbox1 赋值 从1加到500
timer2为textbox2 赋值 从1加到500
一对一的这种
NET 控件数组代码想要调整下
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
5条回答 默认 最新
- soar3033 2021-08-05 11:54关注
这样就行
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WinFormsApp5 { public partial class Form1 : Form { Timer[] timers=new Timer[5]; TextBox[] textBoxes=new TextBox[5]; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < 5; i++) { Timer t = new Timer(); TextBox tb = new TextBox(); tb.Size = new Size(50,30); tb.Location = new Point(50,150+i*40); tb.Text = "0"; t.Interval = 400+i*400; t.Tick += delegate { tb.Text=(int.Parse(tb.Text)+1).ToString(); }; textBoxes[i] = tb; timers[i] = t; this.Controls.Add(tb); } for (int i = 0; i < 5; i++) { timers[i].Start(); } } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 多址通信方式的抗噪声性能和系统容量对比
- ¥15 winform的chart曲线生成时有凸起
- ¥15 msix packaging tool打包问题
- ¥15 finalshell节点的搭建代码和那个端口代码教程
- ¥15 Centos / PETSc / PETGEM
- ¥15 centos7.9 IPv6端口telnet和端口监控问题
- ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
- ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
- ¥20 海浪数据 南海地区海况数据,波浪数据
- ¥20 软件测试决策法疑问求解答