zoukankan      html  css  js  c++  java
  • 控件名称获取与设置

    private void button6_Click(object sender, EventArgs e)
    {
      this.listBox1.Items.Clear();

      FieldInfo[] FieldInfos = this.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

      foreach (FieldInfo theFieldInfo in FieldInfos)
      {
        PropertyInfo thePropertyInfo = theFieldInfo.FieldType.GetProperty("Text");

        if (thePropertyInfo == null) continue;

        string ctrlName = theFieldInfo.Name;
        string className = theFieldInfo.FieldType.ToString();
        string oldValue = thePropertyInfo.GetValue(theFieldInfo.GetValue(this), null).ToString();
        string newValue = "昆山";


        string Line1 = string.Format("类名={0} 控件名称={1}", className, ctrlName);
        string Line2 = string.Format("老值={0} 新值={1}", oldValue, newValue);
        this.listBox1.Items.Add("");
        this.listBox1.Items.Add(Line1);
        this.listBox1.Items.Add(Line2);

        thePropertyInfo.SetValue(theFieldInfo.GetValue(this), "玉", null);
      }
    }

  • 相关阅读:
    面向对象中一些容易混淆的概念
    day12作业
    day10作业
    day09作业
    Where与Having的区别
    排序算法之快速排序
    排序算法之冒泡排序
    jQuery中的100个技巧
    用node.js给图片加水印
    代码高亮美化插件-----SyntaxHighlighter
  • 原文地址:https://www.cnblogs.com/LongHuaiYu/p/5879626.html
Copyright © 2011-2022 走看看