改变rad控件的形式

时间:2011-01-26 05:49:10

标签: c# telerik rad-controls

如何在表单中访问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 = ....
            }
     }
 }

感谢

1 个答案:

答案 0 :(得分: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);
    }
  }
}