-6
我有一个问题。如何从MyControl(按钮)获取按钮文本?
用户控件
Button : UserControl
...
public string naz
{ get { return this.button1.Text; } }
...
在我的形式,我可以做到这一点
if(button0.naz == "1"){ MessageBox.Show("My Text"); }
if(button1.naz == "1"){ MessageBox.Show("My Text"); }
if(button2.naz == "1"){ MessageBox.Show("My Text"); }
但是,当我尝试以下方法.naz
无法识别。
for(int i=0;i<=60;i++)
{
if(this.Controls["button" + i.ToString()).naz == "1")
{
MessageBox.Show("My Text");
}
}