如何识别单击了哪个按钮

如何识别单击了哪个按钮

本文介绍了如何识别单击了哪个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



i正在用AddHandler做一些实验,只需几个按钮



的例子

如果我已经在一个表单中创建了2个按钮

如何确保ii点击第一个按钮它会弹出一个msgBox(按钮1)和按钮对于msgBox(按钮2)



如何识别哪个按钮被点击?



我尝试了什么:



for i as integer = 0 to 1



dim _button as new button



with _button







结束



next



AddHandler _button.Click,_buttonClicked的地址





private sub _buttonClicked(byVal _sender as object,byVal _e as EventArgs){

'if button 1点击

'MsgBox(按钮1)



'如果点击按钮2

' MsgBox(按钮2)

}

解决方案



hello,

i was doing some experiment on AddHandler with a few button

for an example
if i already create 2 buttons in a form
how to make sure that i i click on the 1st button it will pop out a msgBox("button 1") and button for a msgBox("button 2")

how to indentify which button was click??

What I have tried:

for i as integer = 0 to 1

dim _button as new button

with _button



end with

next

AddHandler _button.Click , address of _buttonClicked


private sub _buttonClicked ( byVal _sender as object , byVal _e as EventArgs){
'if button 1 was clicked
'MsgBox("Button 1")

'if button 2 was clicked
'MsgBox("Button 2")
}

解决方案



这篇关于如何识别单击了哪个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 04:28