按钮的生成代码如下
for(int cnt=0;cnt<i;cnt++)
{
newButton = new Button();
newButton.Text = menuText;
newButton.Location = new System.Drawing.Point(locX,locY);
locY += 23;
this.Controls.Add(newButton);
}
我怎么来为这些按钮写点击事件代码呢?
for(int cnt=0;cnt<i;cnt++)
{
newButton = new Button();
newButton.Text = menuText;
newButton.Location = new System.Drawing.Point(locX,locY);
locY += 23;
this.Controls.Add(newButton);
}
我怎么来为这些按钮写点击事件代码呢?
解决方案 »
- C#操作INI文件
- 如何让Winform的DataGridView合并表头
- C# 求教一个不算好难的功能 Distinct()的值
- asp.net区暂时没人解(赋链接) 200分+105分 专家们该起床了
- 我要用多线程在窗体控件中加入数据,让窗体不卡,怎么办?/给个代码吧
- Response.Write一个window.open来弹出窗口,如何不刷母页面?
- 从codeproject下载的源代码怎么打不开了?
- 求助:请帮我看看这段代码为什么是死循环,谢谢!
- 求助IP控制用户名登录
- DrawString的莫名其妙的事情
- 求助~~~~~~~~~关于OnPaint()和Form1_Paint()的区别
- 使用临时表的分页存储过程 出问题了
+= 出来的时候.net会自动给你生成一个方法连按两下Tab键
{
newButton = new Button();
newButton.Text = menuText;
newButton.Location = new System.Drawing.Point(locX,locY);
locY += 23;
this.Controls.Add(newButton);
newButton.Click +=new EventHandler(newButton_Click);
} 然后newButton_Click方法里面就是你点击按钮要做的是。
private ovid newButton_Click(object sender,System.EventArgs e)
{
}