如何在vb.net中动态删除创建控件?
问题描述:
Hai
如何从vb表单中动态创建图片框?通过指定需要从表单中删除控件的名称或文本,
实际上我将动态创建图片框并且它会点击我将得到名称,使用该名称我需要删除control.if代码执行相同的图片它没有删除,所以需要捕获全局变量中的名称,执行后点击事件可以删除控件吗?
问候
Aravind
Hai
How to remove dynamically create picture box from vb form ? by specify the name or text need to remove control from form ,
Actually i will create picture box dynamically and its rigth click i will get name ,using that name i need to remove control.if code execute in same picture it not remove,so need to capture name in global variable and after execute click event can remove control ?
Regards
Aravind
答
当您右键单击控件时,处理程序方法将传递给sender
参数。
您可以使用 Controls.Remove [ ^ ]通过将该实例传递给方法来从表单中删除控件。
When you right click on the control, the handler method is passed the instance in thesender
parameter.
You can use Controls.Remove[^] to remove the control from your form by passing that instance to the method.