本文介绍了获取已动态生成的按钮的文本属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...我写了一段代码来生成动态按钮及其事件.

我希望text属性对单击的按钮执行某些操作.


生成我编写的动态事件

Button btn = new Button();
btn.Click + =新的EventHandler(btn_Click);


事件是

hi guys...i have written a piece of code to generate dynamic buttons and its events.

i want the text property to perform some operation of the button that has been clicked.


to generate dynamic events i have written

Button btn = new Button();
btn.Click += new EventHandler(btn_Click);


and the event is

private void btn_Click(object sender, EventArgs e)
  {
      // here i want text property of button clicked
  }



请帮忙...

谢谢...! :)



please help...

thanx...! :)

推荐答案

private void btn_Click(object sender, EventArgs e)
  {
  Button myButton = sender as Button;
  if (myButton != null)
     {
     string myButtonText = myButton.Text;
     ...
     }
  }


这篇关于获取已动态生成的按钮的文本属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 18:50