change property of rad controls in form
How can I access a property of rad controls in my form. something like code bellow
foreach (Control ctrl in this.Controls)
开发者_Python百科 {
RadControl rc = ctrl as RadControl;
if (rc != null)
{
if (rc.GetType() == typeof(Telerik.WinControls.UI.RadButton))
{
rc.Image = ....
}
}
}
thanks
In your conditional statement you want to test if (ctrl is RadControl)
And you want to make this into a recursive function that will go down through all Control collections in the page.
private void DoSomethingToRadControls(ControlCollection controls) {
if (controls != null && controls.Any()) {
foreach (Control ctrl in controls) {
if (ctrl is RadControl) {
// do something
}
DoSomethingToRadControls(ctrl.Controls);
}
}
}
精彩评论