请教个winform的问题 如何在winform窗体中动态生成常用的winform的控件呢?如textbox ,label 等 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 TextBox tb = new TextBox(); tb.Left = 10; tb.Top = 10; this.Controls.Add(tb); 打开窗体中的 private void InitializeComponent()方法看看就清楚了。如下: .... // // button1 // this.button1.Location = new System.Drawing.Point(229, 270); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 1; this.button1.Text = "button1"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(564, 429); this.Controls.Add(this.button1); this.Controls.Add(this.c1FlexGrid1); this.Name = "Form1"; this.Text = "Form1"; ..... Label lb = new Label();lb.Size = new Size(100,20);lb.Location = new Point(20,20);this.Controls.Add(lb); 恩,没错,拉个textbox放上去,看看系统自动生成的代码,照着敲就是了 TextBox[] tb = new TextBox[5];for(int i=0;i<5;i++){ tb[i]=new TextBox(); tb[i].Width=80 tb[i].Left = 30+90*i; tb[i].Top = 30; this.Controls.Add(tb[i]);} 如果控件不多,先放在指定位置,然后visiable = false,用的时候改为true就行了 哎,来迟一步,还接!如dugupiaoyun(独孤飘云) 所言。 谁有遇到过httpwebrequest模拟登录出现(503) Server Unavailable.这个错误? 调查了3天的问题:在VS中运行与直接运行的区别? Linux系统下的Ftp服务器 快速插入问题 关于判断datagrid是否打开的问题!在线等...谢谢啦! 请问如何实现处理信息的即时显示? 如何赋值? 请问如何在控件调用父页面的方法(或属性) 求:数据从一个数据库中转到另一个数据库的解决方案!表结构相同! 一个Convert类的问题? VS2005怎么设置启动窗体啊? 大家快来加入咱.net爱好者群30081753
tb.Left = 10;
tb.Top = 10;
this.Controls.Add(tb);
....
//
// button1
//
this.button1.Location = new System.Drawing.Point(229, 270);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(564, 429);
this.Controls.Add(this.button1);
this.Controls.Add(this.c1FlexGrid1);
this.Name = "Form1";
this.Text = "Form1";
.....
lb.Size = new Size(100,20);
lb.Location = new Point(20,20);this.Controls.Add(lb);
for(int i=0;i<5;i++)
{
tb[i]=new TextBox();
tb[i].Width=80
tb[i].Left = 30+90*i;
tb[i].Top = 30;
this.Controls.Add(tb[i]);
}
如dugupiaoyun(独孤飘云) 所言。