Change RadMenuItems visibility in controls collection

5 posts, 1 answers
  1. Ali
    Ali avatar
    2 posts
    Member since:
    Apr 2011

    Posted 18 Jan 2013 Link to this post

    Hi all,

    I have a RadMenu1 control, with inside 10  controls (named RadMenuItem1,RadMenuItem2,RadMenuItem3,...

    How can I change the visibility of the RadMenuItem elements in a loop ?

    I try to use :
    for i=1 to 10   me.controls("RadMenuItem" & i.tostring).visible=False or True   but it don't work !

    Thanks
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2013 Link to this post

    Hi,

    Try the following code snippet to achieve your scenario.

    VB:
    For i As Integer = 0 To 9
        RadMenu1.Items(i).Visibility = ElementVisibility.Hidden
        'or
        RadMenu1.Items(i).Visibility = ElementVisibility.Visible
    Next

    Hope this helps.

    Regards,
    Princy.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 21 Jan 2013 Link to this post

    Hello,

    Thank you for writing.

    To hide an item, you should set the items' Visibility property to Hidden or Collapsed. 

    I hope this helps.

    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  5. Ali
    Ali avatar
    2 posts
    Member since:
    Apr 2011

    Posted 21 Jan 2013 Link to this post

    Hi Princy,
    By this code i can change visibility of main menu. How to do that for sub menu.
    Thank you.
  6. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2013 Link to this post

    Hi,

    Try the following code snippet to change the visibility of sub RadMenuItems.

    C#:
    for (int i = 0; i < 2; i++)
       {
          RadMenuItem item=(RadMenuItem)RadMenu1.Items[i];
          if (item.Items.Count > 0)
             {
               for (int j = 0; j < item.Items.Count; j++)
                 {
                    item.Items[j].Visibility = ElementVisibility.Hidden;
                 }
             }
       }

    Hope this helps.

    Regards,
    Princy.
Back to Top
UI for WinForms is Visual Studio 2017 Ready