C# 根据控件NAME名字 操作控件
秀啊!
现在知道一个字符串“label1”
想根据这个“label1”操作窗体内 label1控件的TEXT值
答案:
string name = "label1";
object o = this.GetType().GetField(name, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
((Label)o).Text = "hello world!";
转载:https://blog.csdn.net/pencher_liu/article/details/82462356
还剩一根头发,两根头发,三根头发,四根头发。。。。。。

浙公网安备 33010602011771号