单击按钮创建动态文本框和按钮. [英] create dynamic textboxes and a button on click of a button.
本文介绍了单击按钮创建动态文本框和按钮.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友,
我正在开发一个Windows应用程序,在其中我要动态创建8个文本框和一个按钮(在运行时单击按钮时单击事件).
有人可以帮我吗?
提前谢谢.
Shailesh J.
:-)
Dear friends,
I am developing a windows application in which i want to create 8 textboxes and a button dynamically (on run time-on click event of a button).
Can anybody help me for same.
Thanks in advance.
Shailesh J.
:-)
推荐答案
尝试:
for (int i = 0; i < 8; i++)
{
TextBox tb = new TextBox();
Controls.Add(tb);
}
Button but = new Button();
Controls.Add(but);
您必须自己设置各种控件的位置,文本和大小,但这取决于您-我不知道您想如何布置它们.
You will have to set the Location, Text and size of the various controls yourself, but that is up to you - I don''t know how you want to arrange them.
尝试一下:
在Winforms中运行时添加和删除控件 [ ^ ]
Try this:
Runtime Adding and Removing of Controls in Winforms[^]
这篇关于单击按钮创建动态文本框和按钮.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文