遍历Dev LayoutControl中的所有控件信息

这是Form界面,如下图:

namespace WindowsFormsApplication1
{
  public partial class Form2 : Form
  {
    public Form2()
    {
      InitializeComponent();
    }

  protected override void OnLoad(EventArgs e)
  {
    textEdit1.Text = "AAA";
    textEdit2.Text = "BBB";
    textEdit3.Text = "CCC";
    textEdit4.Text = "DDD";

    //把四个textEdit都可以取出来
    foreach (var it in layoutControlGroup1.Items)
    {
      //var tmp = it.GetType();
      var tmp = it as LayoutControlItem;

      var first = tmp.Text;//ID,Name,Age,Adress
      var second = tmp.Control.Text;//AAA,BBB,CCC,DDD
      MessageBox.Show(first.ToString() + "," + second);//输出
    }

    base.OnLoad(e);
  }
 }
}

 

posted @ 2014-04-18 17:24  帅刺猬之家  阅读(1219)  评论(0编辑  收藏  举报