Findcontrol to find a radbuttonelement?

6 posts, 0 answers
  1. Walther Siksma
    Walther Siksma avatar
    12 posts
    Member since:
    May 2006

    Posted 25 Jun 2009 Link to this post

    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!


     

     


     
     

     

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 26 Jun 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Walther Siksma
    Walther Siksma avatar
    12 posts
    Member since:
    May 2006

    Posted 28 Jun 2009 Link to this post

    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

     

  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 02 Jul 2009 Link to this post

    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.
  6. Cristian Apavaloaiei
    Cristian Apavaloaiei avatar
    25 posts
    Member since:
    Aug 2008

    Posted 10 Aug 2010 Link to this post

    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 ?

  7. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 13 Aug 2010 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready