如何使用button_click eventhandeler传递Integer值 [英] How to pass an Integer value with button_click eventhandeler

查看:56
本文介绍了如何使用button_click eventhandeler传递Integer值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态按钮btnQuestionNum和一个整数i,

I have a dynamic button btnQuestionNum and a integer i,

btnQuestionNum= new Button();
btnQuestionNum.Text = Convert.ToString(i + 1);
btnQuestionNum.ID = i.ToString();
btnQuestionNum.Click += new EventHandler(btnDynamic);
placeholder.Controls.Add(btnQuestionNum);



我想在点击按钮btnQuestionNum时传递i的值。


I want to pass the value of i when button btnQuestionNum is clicked.

推荐答案

尝试类似:

Try something like:
btnQuestionNum.Click += (sender, e) => { MyHandler(sender, e, i); }; 

void MyHandler(object sender, EventArgs e, int i)
{
    //use int i here
}



我只是告诉你一个如何做的例子,希望你应该明白该怎么做。


I just show you an example how it could be done,hope you should understand what to do.


这篇关于如何使用button_click eventhandeler传递Integer值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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