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

Change RadMenuItems visibility in controls collection

4 Answers 292 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 19 Jan 2013, 04:32 AM
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

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jan 2013, 06:16 AM
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.
0
Stefan
Telerik team
answered on 21 Jan 2013, 09:28 AM
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.
0
Ali
Top achievements
Rank 1
answered on 21 Jan 2013, 12:20 PM
Hi Princy,
By this code i can change visibility of main menu. How to do that for sub menu.
Thank you.
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Jan 2013, 05:52 AM
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.
Tags
General Discussions
Asked by
Ali
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Stefan
Telerik team
Ali
Top achievements
Rank 1
Share this question
or