单击一个按钮时如何创建更多按钮? [英] How to create more buttons when one button is clicked?

查看:81
本文介绍了单击一个按钮时如何创建更多按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows窗体应用程序 - Visual Studio C#2011

你好


首先,我是C#的新手。


初始表单将有1个名为Add的按钮。和1个文本框。


我想创建一个执行以下操作的程序:当按钮添加时单击,如果文本框中写有任何文本,将在添加按钮下创建一个按钮。一个名称出现在文本框中。


每次单击时,都会在最后一个按钮下创建一个新按钮。


考虑上课,但不知道该放什么。


例如:

Windows Forms Applications - Visual Studio C# 2011

Hello

First of all, I am really new to C#.

The initial form will have 1 button named "Add" and 1 text box.

I would like to create a program that does the following: when the button "Add" is clicked, if there is any text written in the text box, a button will be created, under the "Add" one with the name that appears in the text box.

Each time it is clicked, a new button will be created under the last button.

Was thinking of making a class but am not sure what to put in it.

For example:

展开 | 选择 | Wrap | 行号

推荐答案

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


非常感谢您回复的速度


然而它没有做任何事情:(

感谢您的评论办法。至少这给了我一个强大的基础,我应该开始。


我还得更换
Thank you very much for the speed at which you replied

However it doesn''t do anything :(
Thanks for the commentaries by the way. At least this gives me a strong base where I should start.

Also I had to replace
展开 | 选择 | 换行 | 行号


对不起,我用btnIndex犯了一个错误,你是对的,我纠正了它。


它对我有用。


您是否向AddMore.Click事件添加了方法btnAdd_Click?


编辑:

我更正了我的代码所以现在它与你的名字一起工作有你的项目。

添加的按钮现在称为AddMore,用于获取文本的TextBox是c alled:textBox1。
sorry, I made a mistake with btnIndex, you are right, I corrected it.

It works for me.

Did you add a method btnAdd_Click to the AddMore.Click event?


I corrected my code so now it shoud work with names you have on your project.
Button for adding is called AddMore now, TextBox for getting a text for buton is called: textBox1.


这篇关于单击一个按钮时如何创建更多按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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