在Winforms C#中删除选定的控件 [英] Delete selected controls in Winforms C#

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

问题描述

我需要点击一个按钮,然后选择"选择"按钮。该按钮,并通过单击一个擦除按钮,该控件将被删除。我怎么能这样做?。

**上涨**

I need to click on a button, "select" that button, and by clicking on an erase button, that control will be deleted. How could I do that ?.
**Up da te**

当你点击垃圾按钮时,我需要"选择模式"。打开(一个bool变量变为true),当你点击那个控件(让我们说一个按钮)时,应用程序"选择它"。
和另一个按钮,(确定按钮)应用程序应该知道您点击的Wich控件,然后删除它们,我所拥有的问题是识别女巫控制你选择的。

推荐答案

您不希望用户点击该按钮,因为这会触发正常的"点击"按钮。该按钮的操作。 你无法分辨出"行动"与"行动"之间的区别。和"我准备删除"。

You wouldn't want the user to click the button, because that would trigger the normal "click" action for that button.  You couldn't tell the difference between "do the action" and "I'm preparing to delete".

你可能需要一个"模式"。为此。 我的意思是,点击一个按钮进入"选择"按钮模式,然后使用橡皮筋矩形(网络上提供)选择要影响的控件。 然后在选择控件后选择
,选择"删除"。

You are probably going to need to have a "mode" for this.  What I mean is, click one button to go into "select" mode, then use a rubber-band rectangle (available on the web) to select which control or controls to affect.  Then after controls are selected, pick "Delete".

替代方案,您可以让他们点击"删除"按钮。首先,让他们选择要删除的控件。 这需要在您的应用中添加一些额外的代码,以便Click处理程序具有类似

Alternative, you could have them click "Delete" first, then have them choose the control to delete.  That would require a little extra code in your app so that the Click handler has something like

的内容。   if(我们处于'删除'模式)

    {

       去删除此控件;

    }¥b $ b   否则

    {

       采取常规点击操作;

    }

    if (we are in 'delete' mode )
    {
        go delete this control;
    }
    else
    {
        take the regular click action;
    }


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

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