0

如何在我的表单中访问 rad 控件的属性。类似于下面的代码

foreach (Control ctrl in this.Controls)
  {
   RadControl rc = ctrl as RadControl;
    if (rc != null)
       {
           if (rc.GetType() == typeof(Telerik.WinControls.UI.RadButton))
            {
              rc.Image = ....
            }
     }
 }

谢谢

4

1 回答 1

0

在您要测试的条件语句中if (ctrl is RadControl)

你想把它变成一个递归函数,它将遍历页面中的所有 Control 集合。

private void DoSomethingToRadControls(ControlCollection controls) {
  if (controls != null && controls.Any()) {
    foreach (Control ctrl in controls) {
      if (ctrl is RadControl) {
        // do something
      }
      DoSomethingToRadControls(ctrl.Controls);
    }
  }
}
于 2011-01-26T06:52:14.790 回答