多个按钮一个控制变量 [英] multiple buttons one control variable

查看:146
本文介绍了多个按钮一个控制变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



多个按钮是否可以有一个控制变量?

我正在创建一个屏幕键盘,需要将每个用户按钮的类型定义为派生自CButton类.

我不想为要调用的DrawItem()函数的每个按钮制作单独的变量.


救命啊! :(

Hi,

is it possible to have one control variable for multiple buttons?

i am creating an onscreen keyboard and need to make each button of a user defined type that is derived from CButton class.

i dont want to make a separate variable for each button for the DrawItem() function to be called.


Helppp!! :(

推荐答案

使用发送方对象来确定按下了哪个按钮.

在您的OnClickEvent状态下:
use the sender object to determine which button was pressed.

in your OnClickEvent state:
Button clickedOne = (Button) sender;



现在,您可以访问按钮的ID或Text属性,并执行您想做的事情



You can now access ID or Text properties of the button and do what you want to do


这篇关于多个按钮一个控制变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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