如何在VB.NET中不需要的对象 [英] How to unwanted object in VB.NET

查看:79
本文介绍了如何在VB.NET中不需要的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个程序



每当点击其他对象时

它会删除按钮



有什么建议怎么办?

我应该为所有这些物品添加手柄吗?



我尝试过的事情:



i am doing a program

whenever click on other objects
it will remove the button

any advice how to do it?
should i addHandler to all of those objects?

What I have tried:

i am doing a program

whenever click on other objects
it will remove the button

any advice how to do it?
should i addHandler to all of those objects?

推荐答案

如果你想做什么 - 什么 - 当他们用户互动时使用您的应用程序,您必须处理他们可能采取的每个操作的事件。所以是的,要让其他对象对点击作出反应,他们必须每个都添加一个Click事件处理程序。

要从点击处理程序中删除相同的按钮,只需在处理程序中指定它:

If you want to do something - anything - when they user interacts with your app, you have to handle an event for each action they may take. So yes, to have "other objects" react to a click they must each have a Click event handler added.
To remove the same button from the click handlers just specify it in the handler:
Controls.Remove(myButton)



要删除用户点击的对象,同样简单:


To remove the object the user clicked, is equally simple:

Controls.Remove(sender)



在这两种情况下,您可以与所有控件共享相同的处理程序方法,您不需要每个单独的代码。


In both cases, you can share the same handler method with all the controls, you don't need separate code for each.


这篇关于如何在VB.NET中不需要的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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