This is a migrated thread and some comments may be shown as answers.

Findcontrol to find a radbuttonelement?

5 Answers 245 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Walther Siksma
Top achievements
Rank 2
Walther Siksma asked on 25 Jun 2009, 03:11 PM
Hi,
I'd like to find a radbuttonelement on a ribbonbar to set it's enabled property (disable menu items which the user is not allowed to use).


I tried this:

FindControl("rbeAdmin").Enabled =True

using this function:

Private Function FindControl(ByVal strControlName As String) As Control

 

 

If ((strControlName.Length = 0) _

 

 

OrElse (Me.Controls.Find(strControlName, True).Length = 0)) Then

 

 

Return Nothing

 

 

End If

 

 

Return Me.Controls.Find(strControlName, True)(0)

 

 

End Function



But the default me.controls.find does not find the nested telerik controls. Has anyone a smart idea on how find these controls by name?
thnx!


 

 


 
 

 

5 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 26 Jun 2009, 06:32 PM
Hello Walther,

The Controls.Find() method searches the controls collection of your Control instance. RadButtonElement and all elements for that matter, do not inherit from control and are therefore in a different collection (RadItemOwnerCollection or RadItemCollection). I am afraid that our controls do not provide an automatic way to search for nested elements, you will have to explicitly loop through the various items collections to find your required element.

Another thing you can do, is to create a list of RadElement and whenever you add or remove an element to your controls, you also add it to the list (and remove it from the list when you remove it from a control). This way you will always have a container with all elements and you will e able to find whichever you need.

Write back if you need further assistance.

All the best,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Walther Siksma
Top achievements
Rank 2
answered on 28 Jun 2009, 04:06 PM
Hello Victor, thnx for the reply.
I cannot image I'm the only one in need of a way to enable of disable specific elements in a Ribbonbar. Could you elaborate a bit more with a little sample?
Trying this:

For Each ct As RadItem In RadRibbonBarCommandTab1.Items

 

Debug.Print(ct.Name)

 

Next


Allows me to iterate through the items of a specifc CommandTab.

But trying it in a more generic way (without knowing the amount of CommandTabs beforehand ) then the items collection is not available

For

 

Each ct As RadItem In Me.RadRibbonBar1.CommandTabs

 

 

    For Each cti As RadItem In ct.Items

 

        Debug.Print(cti.Name)

 

    Next

 

 

Next

 


Tabs/chunks/groups/items , How can I reach the buttonelements?
Building an entire structure in the designer and then manually building a list of items I would like to enable or disable does not seem like a efficient way to this. Hardcoding each item is not an option.
 

Any further help appreciated
thnx
Walther

 

0
Victor
Telerik team
answered on 02 Jul 2009, 07:32 AM
Hi Walther,

As I stated previously, there is no general (and safe) way to iterate over every single collection.

In your RadRibbonBar control you have a RootElement property which contains a Children collection. You can use it to iterate over all elements. You will have to perform casts in order to see if the current element in the loop is a RadButtonElement for example.

If you are not going to create buttons or other interface widgets dynamically I suggest you identify the ones which will need to be disabled/enabled and keep a collection which contains only them.

All the best,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Cristian Apavaloaiei
Top achievements
Rank 2
answered on 10 Aug 2010, 11:10 AM

Hi. I am using Q1 2010 on my application. I have cutomize some controls that are necessary to work with a radribbonbar; (ribbonbar, tab, group, groupButton and radElements). Reading the upper discussion i understood that in order to easily access different controls from the ribbonMeniu i  have to create a list. When should i add items to that list and where? or..what are the events handled when adding an item from designer ?

0
Peter
Telerik team
answered on 13 Aug 2010, 12:49 PM
Hello Cristian Apavaloaiei,

Thank you for writing.

Would you be able to provide more details about your concrete scenario?  How would like to customize your elements? Why do you require a list and what prevents you from directly accessing the element instances?
 
You are able to subscribe to all  the element events in design time. However, we do not provide design-time hooks, because the design-time behavior is not customizable.

I am looking for your response.

Regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RibbonBar
Asked by
Walther Siksma
Top achievements
Rank 2
Answers by
Victor
Telerik team
Walther Siksma
Top achievements
Rank 2
Cristian Apavaloaiei
Top achievements
Rank 2
Peter
Telerik team
Share this question
or