如何将控件动态添加到 ASP.NET 表单? [英] How to add controls dynamically to ASP.NET form?

查看:25
本文介绍了如何将控件动态添加到 ASP.NET 表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何使用 C# .net 将控件动态添加到表单中.谁能帮我?我在 vb.net 中知道这一点,但我需要知道 C# 中的语法.

I do not know how to add controls dynamically to the form using C# .net. Can anyone help me? I know this with vb.net but I need to know the syntax in C#.

推荐答案

在表单中,以下代码可以动态添加按钮:

In the form, the following code can add a button dynamically:

Button button1 = new Button();
button1.Text = "dynamic button";
button1.Left = 10; button1.Top = 10;  //the button's location
this.Controls.Add(button1);

这篇关于如何将控件动态添加到 ASP.NET 表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆