Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 更改窗体中rad控件的属性_C#_Telerik_Rad Controls - Fatal编程技术网

C# 更改窗体中rad控件的属性

C# 更改窗体中rad控件的属性,c#,telerik,rad-controls,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 = .

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

感谢您在条件语句中测试
是否(ctrl为RadControl)

您希望将其转换为递归函数,该函数将遍历页面中的所有控件集合

private void DoSomethingToRadControls(ControlCollection controls) {
  if (controls != null && controls.Any()) {
    foreach (Control ctrl in controls) {
      if (ctrl is RadControl) {
        // do something
      }
      DoSomethingToRadControls(ctrl.Controls);
    }
  }
}

谢谢你的回复,但没用。radcontrol按钮具有属性(图像)。在此状态下,如果(ctrl为RadControl){ctrl.Image=…}ctrl没有Image属性。我无法访问控件的image属性尝试时会发生什么?测试此=>private void DoSomethingToRadControls(ControlCollection控件){if(controls!=null){foreach(controls中的Control ctrl){if(ctrl是RadControl){ctrl.image=…}}}}只是一个想法,但也许可以尝试将ctrl转换为RadButton?i、 e.
(RadButton)rc.Image=…