TreeNode[] mynode = new TreeNode[5];
for (int i = 0; i<=5-1; i++)
{
mynode[i] = new TreeNode();
mynode[i].Text = i.ToString();
}
treeView1.Nodes.Add(mynode);
for (int i = 0; i<=5-1; i++)
{
mynode[i] = new TreeNode();
mynode[i].Text = i.ToString();
}
treeView1.Nodes.Add(mynode);
解决方案 »
- VS2008 C# WM6开发TXT阅读器,关联文件后如何实现多实例(多开)?
- 请教高人在程序中修改系统path变量,要求修改后不重启就生效
- 如何从窗口B访问窗口A的某个控件?
- c# 处理多图片合并成一张大图的问题
- C#中如何把二进制字符串转化为二进制
- 怎样把一个数组的某段元素copy到另一个数组?
- 请问c#怎样处理这样的字节数组?亟待
- QQ群:ASP.Net With C#,欢迎加入!
- 聊个MVC的话题 web api有用吗
- 请问如何判断用户在TextBox 里填入的是 IP 地址还是域名字符串?
- 注册 COM Interop 失败 的问题
- 开发页面都用什么控件(是web控件还是html的控件)
{
Button buttons=new Button[10];
for(int i=0;i<buttons.Count;i++)
{
buttons[i]=new Button();
this.Controls.Add(buttons[i]);
buttons[i].Click=Click += new System.EventHandler(this.buttons_Click)
}
}private void buttons_Click(object sender, System.EventArgs e)
{
//....
}
2. D:\MyWork\C#\ZHBL3\ZHBL3\FrmTest.cs(86): “System.Windows.Forms.Button”并不包含对“Count”的定义
3. D:\MyWork\C#\ZHBL3\ZHBL3\FrmTest.cs(88): 无法将带 [] 的索引应用于“System.Windows.Forms.Button”类型的表达式我是初学者,能不能在详细些呢?以前用VB,现在准备转过来,谢谢了。
{
Button[] buttons=new Button[10];
for(int i=0;i<buttons.Length;i++)
{
buttons[i]=new Button();
this.Controls.Add(buttons[i]);
buttons[i].Click += new System.EventHandler(this.buttons_Click);
}
}
private void buttons_Click(object sender, System.EventArgs e)
{
//....
}
class YourForm : Form
{
private System.Windows.Forms.TextBox[] textboxes;....
int n = 10;
int nLeft = 10;
int nTop = 10;
int nHeight = 30;
textboxes = new TextBox[n];
for (int i=0; i < n; i++)
{
textboxes[i] = new TextBox();
textboxes[i].Name = "txt" + i.ToString();
textboxes[i].Location = new System.Drawing.Point(nLeft, i*nHeight + nTop);
this.Controls.Add(textboxes[i]);
}
http://www.programfan.com/showarticle.asp?id=2073看看这个吧