如何选择并单击Flowlayoutpanel中的第一个按钮,单击鼠标并且在运行时模式下我不知道第一个按钮的名称 [英] How Can I Select And Click The First Button In The Flowlayoutpanel With Out Mouse Clicking And I Don't Know The Name Of The First Button, In The Run Time Mode

查看:60
本文介绍了如何选择并单击Flowlayoutpanel中的第一个按钮,单击鼠标并且在运行时模式下我不知道第一个按钮的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何选择并单击Flowlayoutpanel中的第一个按钮,使用鼠标单击并且我不知道第一个按钮的名称,在运行时模式下

How Can I Select And Click The First Button In The Flowlayoutpanel With Out Mouse Clicking And I Don't Know The Name Of The First Button, In The Run Time Mode

推荐答案

使用WinForms按钮控件的'PerformClick方法[ ^ ]。



当然,表格应该显示(激活) )在你打电话之前)。
Use the 'PerformClick method of the WinForms Button Control [^].

Of course, the Form should be shown (activated) before you call this).


请看我对问题和解决方案的评论1.



常规方法是抽象的来自处理程序的逻辑操作。这是通过编写实现所需效果的单独方法来完成的。这样,这个单独的方法可以从多个地方调用:从你单击处理程序和其他地方。



如果你有更具体的关注,你可以获得更详细的建议与你的代码相关。







另一个更具体的方法是利用a控制,或控制内部的选择。你不只是点击一个控件;点击可能会改变选择或聚焦。处理选择和聚焦事件可能需要一些副作用。然后,您可以通过编程方式更改聚焦或选择。



-SA
Please see my comment to the question and Solution 1.

The regular approach is abstracting of logical action from the handler. This is done by writing a separate method implementing the desired effect. This way, this separate method could be called from more than one place: from you click handler and elsewhere.

You can get more detailed advice if you have more specific concern related to your code.



Another, more specific approach is leveraging focusing of a control, or selection inside control. You don't just "click" on a control; the click may change selection or focusing. Handling selection and focusing event may need some side-effect action. And then, you can change focusing or selection programmatically.

—SA


谢谢你你的努力

解决了



thank you for your efforts
Solved

Button btn1 = flpGroup.Controls.Find("btn1", true).FirstOrDefault() as Button;
            btn1.PerformClick();
            btn1.Select();


这篇关于如何选择并单击Flowlayoutpanel中的第一个按钮,单击鼠标并且在运行时模式下我不知道第一个按钮的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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