Dynemically在c#中添加和删除控件 [英] Dynemically Add and Remove Control in c#

查看:77
本文介绍了Dynemically在c#中添加和删除控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii专家



我现在正在使用c#应用程序我想在按添加更多按钮时动态添加c#文本框并删除按钮。



现在,当我按下删除按钮时,它将删除特定的按钮和文本框。



请问有谁帮我解释这个

解决方案

的一步一步的过程创建一个新的Windows窗体项目。只在表单上放一个按钮。现在打开Form1.Designer.cs。在那里,您可以看到自动生成的表单代码。这就是Visual Studio Forms Designer在其中创建表单和控件的方式。



更改代码的价值有限,因为下次更改时会被覆盖设计师的努力和重建你的项目。



而是从代码中学习工作代码的样子。



按照您的意愿使示例复杂化并尝试在另一个项目中执行您想要执行的操作。您可以同时打开多个Visual Studio实例,因此在查看此处项目和尝试项目之间切换很容易。


Hii Experts

I am working on c# application now I want to add c# textbox and remove button dynamically when I press "add more" button.

now when I press remove button it will remove particular button and textbox.

Will any one help me to explain step by step process of this

解决方案

Create a new Windows Forms project. Put only one button on the form. Now open Form1.Designer.cs. There you can see the automatically generated code for your form. This is how the Visual Studio Forms Designer creates forms and controls in them.

Changing code in there has limited value because it will get overwritten the next time you change the slightest nouance in the designer and rebuild your project.

Instead learn from the code there what working code can look like.

Complicate the example at your will and try to do what you want to do in another project. You can have several instances of Visual Studio open at the same time, so switching between the "look here" project and the "trying that" is easy.


这篇关于Dynemically在c#中添加和删除控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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