熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#在winform中查找控件

2022-06-13   來源: .NET編程 

  /// <summary>

  /// 在winform中查找控件

  /// </summary>

  /// <param ></param>

  /// <param ></param>

  /// <returns></returns>

  private SystemWindowsFormsControl findControl(SystemWindowsFormsControl control string controlName)

  {

  Control c;

  foreach (Control c in controlControls)

  {

  if (cName == controlName)

  {

  return c;

  }

  else if (cControlsCount > )

  {

  c = findControl(c controlName);

  if (c != null)

  {

  return c;

  }

  }

  }

  return null;

  }

  //調用

  for (int i = ; i <= ; i++)

  {

  string _box = b + iToString();

  TextBox tb = (TextBox)thisfindControl(groupBox _box);

  tbText = iToString();

  }


From:http://tw.wingwit.com/Article/program/net/201311/12060.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.