Hi,
I have a RibbonBar in my application which contains different RadtabStrip with Chunks and RadButtonElements inside chunks. Now, the problem I am facing is that I need to get through each RadButtonElement on runtime and disable appropriate RadButtonElements according to the condition. The only unique way to identify radbuttonelement is through its name. I am using recursive algorithm to check each element 1 by 1... I tried using 'subelement.Name' property to identify the control but its showing me empty string for all the control names. can anyone help me out with this? I would highly appreciate any help possible.
Thanks
Par
I have a RibbonBar in my application which contains different RadtabStrip with Chunks and RadButtonElements inside chunks. Now, the problem I am facing is that I need to get through each RadButtonElement on runtime and disable appropriate RadButtonElements according to the condition. The only unique way to identify radbuttonelement is through its name. I am using recursive algorithm to check each element 1 by 1... I tried using 'subelement.Name' property to identify the control but its showing me empty string for all the control names. can anyone help me out with this? I would highly appreciate any help possible.
Thanks
Par
6 Answers, 1 is accepted
0
Par
Top achievements
Rank 1
answered on 22 Feb 2008, 04:10 PM
Here is the sample code if it helps
if
(controlList.Contains(((Telerik.WinControls.UI.RadButtonElement)subelement).Name))
{
MessageBox.Show(((Telerik.WinControls.UI.RadButtonElement)subelement).Name);
if (bool.Parse(controlList[((Telerik.WinControls.UI.RadButtonElement)subelement).Name].ToString()))
subelement.Enabled =
false;
else
subelement.Visibility = Telerik.WinControls.
ElementVisibility.Hidden;
}
what this code does it that is checks element's name in Hashtable if it is there then it disables or hides the buttonelemt but subelement.Name always appears as "" for all of the button element. However, I have assigned unique name to each buttonelement.
0
Hello Par,
The reason which causes the Name property to return an empty string is that RadButtonElement does not serialize the Name property value in the designer. The Name value that is set is only for its instance name. So you can identify a button by its unique instance name. Please refer to the following snippet:
Serializing the Name property in the designer will be addressed for one of our future releases.
What I can notice from your last post is that you are using Enabled and Visibily properties, but I want to warn you that they are not contrary to each other. This means that when you first set the Visibility to Hidden and then set Enabled to true, your button will not show. Instead, you should use Enabled = true and Enabled = false.
One last thing I would recommend is directly accessing RadButtonElements instances like shown in the code snippet above.
If you need additional assistance, do not hesitate to contact me.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The reason which causes the Name property to return an empty string is that RadButtonElement does not serialize the Name property value in the designer. The Name value that is set is only for its instance name. So you can identify a button by its unique instance name. Please refer to the following snippet:
if (condition) |
{ |
this.radButtonElement1.Enabled = false; |
this.radButtonElement2.Enabled = false; |
this.radButtonElement5.Enabled = false; |
{ |
Serializing the Name property in the designer will be addressed for one of our future releases.
What I can notice from your last post is that you are using Enabled and Visibily properties, but I want to warn you that they are not contrary to each other. This means that when you first set the Visibility to Hidden and then set Enabled to true, your button will not show. Instead, you should use Enabled = true and Enabled = false.
One last thing I would recommend is directly accessing RadButtonElements instances like shown in the code snippet above.
If you need additional assistance, do not hesitate to contact me.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Par
Top achievements
Rank 1
answered on 22 Feb 2008, 07:22 PM
Hello Nikolay,
Thanks for the reply. But, I think I did not explain you properly what I want. As I said in my previous post that I am using recursive algorithm to go through each element in the form to disable or hide element according to the condition. So, I need to identify element on the runtime. I cannot access element as the way you showed it in snippet. To give you clear picture here is a simple example of what I want:
foreach( Element in Form)
{
if(Element.Name == "radBottonElement1")
Element.Enabled = false;
}
thus, instead of using "this.radBottonElement1.Enabled = false" I need to identify button element first and then disable it. Can you please suggest me what is the best way to do it? Thank you for your help
Regards,
Par
Thanks for the reply. But, I think I did not explain you properly what I want. As I said in my previous post that I am using recursive algorithm to go through each element in the form to disable or hide element according to the condition. So, I need to identify element on the runtime. I cannot access element as the way you showed it in snippet. To give you clear picture here is a simple example of what I want:
foreach( Element in Form)
{
if(Element.Name == "radBottonElement1")
Element.Enabled = false;
}
thus, instead of using "this.radBottonElement1.Enabled = false" I need to identify button element first and then disable it. Can you please suggest me what is the best way to do it? Thank you for your help
Regards,
Par
0
Accepted
Hello Par,
As I mentioned, RadButtonElement does not currently have its Name value serialized in the designer. The property that you can use with your code snippet is the Text property, although you cannot be sure that this will provide you with unique values.
Therefore, I would recommend that you adhere to my code snippet - instead of identifying each button through several foreach and if statements, set the necessary properties to the certain controls.
Should you have additional questions, do not hesitate to contact me.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
As I mentioned, RadButtonElement does not currently have its Name value serialized in the designer. The property that you can use with your code snippet is the Text property, although you cannot be sure that this will provide you with unique values.
Therefore, I would recommend that you adhere to my code snippet - instead of identifying each button through several foreach and if statements, set the necessary properties to the certain controls.
Should you have additional questions, do not hesitate to contact me.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Par
Top achievements
Rank 1
answered on 27 Feb 2008, 03:53 PM
Hi Nikolay,
Thanks for the answer. I was just wondering will Tag property of Rad botton work?? or is it not serialized as well??
Par
Thanks for the answer. I was just wondering will Tag property of Rad botton work?? or is it not serialized as well??
Par
0
Par
Top achievements
Rank 1
answered on 27 Feb 2008, 04:37 PM
I tried using tag property and seems like it is working. Thanks for your help.