初试C#,如何在form中动态生成textbox、lable控件

fandajun 2002-12-25 10:18:31
如何在form中动态生成textbox、lable控件
...全文
189 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fandajun 2002-12-25
  • 打赏
  • 举报
回复
给分了
fandajun 2002-12-25
  • 打赏
  • 举报
回复
谢谢,但是编译的时候系统说
“System.Web.UI.WebControls.Label”并不包含对“Location”的定义
还有textbox 的location 、size 定义也没有
qimini 2002-12-25
  • 打赏
  • 举报
回复
来晚了,,,up up
yarshray 2002-12-25
  • 打赏
  • 举报
回复
public void AddMyControls()
{
TextBox textBox1 = new TextBox();
Label label1 = new Label();

// Initialize the controls and their bounds.
label1.Text = "First Name";
label1.Location = new Point(48,48);
label1.Size = new Size (104, 16);
textBox1.Text = "";
textBox1.Location = new Point(48, 64);
textBox1.Size = new Size(104,16);

// Add the TextBox control to the form's control collection.
Controls.Add(textBox1);
// Add the Label control to the form's control collection.
Controls.Add(label1);
}
fandajun 2002-12-25
  • 打赏
  • 举报
回复
高手请进

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧