本文介绍了如何按一下按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在一个If语句中单击一个按钮而无需用户手动执行此操作。除了从Clicked子中复制代码之外我该怎么做?
解决方案
调用sub并传入Nothing,Nothing作为参数。
*****编辑*****
作为一个例子,我在一个按钮的点击事件处理程序中有这个:
Private Sub _
BarButtonItem_Help_General_ItemClick(sender As System.Object,_ $ b $ as As DevExpress.XtraBars.ItemClickEventArgs)_
Handles BarButtonItem_Help_General.ItemClick
Dim sb As New System.Text.StringBuilder
sb.AppendLine("一般情况下,将鼠标悬停在大部分"&b"上)
sb.AppendLine(String.Format(" labels will)向您展示关于&,; Chr(34))的快速{0}一般{0}帮助)
sb.AppendLine(" topic。")
XtraMessageBox.Show(sb。 ToString,"常规帮助",MessageBoxBut tons.OK,MessageBoxIcon.None,DevExpress.Utils.DefaultBoolean.True)
End Sub
为了测试它,我在表单的.Load事件处理程序中使用了它:
BarButtonItem_Help_General_ItemClick(Nothing,Nothing)
结果显示如下:
I want to within an If statement have a button be clicked without the user having to do so manually. How can I do this besides copying the code from within the Clicked sub?
解决方案
Call the sub and pass in Nothing, Nothing as the parameters.
***** EDIT *****
As an example, I have this in a button's click event handler:
Private Sub _ BarButtonItem_Help_General_ItemClick(sender As System.Object, _ e As DevExpress.XtraBars.ItemClickEventArgs) _ Handles BarButtonItem_Help_General.ItemClick Dim sb As New System.Text.StringBuilder sb.AppendLine("In general, hovering your mouse over most of the") sb.AppendLine(String.Format("labels will show you quick {0}general{0} help about the", Chr(34))) sb.AppendLine("topic.") XtraMessageBox.Show(sb.ToString, "General Help", MessageBoxButtons.OK, MessageBoxIcon.None, DevExpress.Utils.DefaultBoolean.True) End Sub
For testing it, I used this in the form's .Load event handler:
BarButtonItem_Help_General_ItemClick(Nothing, Nothing)
The result is shown below:
这篇关于如何按一下按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!