Solved

get list of menuStrip in list view

Posted on 2014-04-21
2
225 Views
Last Modified: 2014-12-01
i want to give user permission of menuStrip items

so i want list of menuStrip items in list view

in c#
0
Comment
Question by:ajaymaster1558
2 Comments
 
LVL 7

Accepted Solution

by:
Utkarsh Kulkarni earned 500 total points
ID: 40012571
Hi,

You can use following

List<ToolStripMenuItem> _lstItems = new List<ToolStripMenuItem>();
foreach (ToolStripMenuItem _tsmItem in menuStrip.Items)
{
    _lstItems.Add(_tsmItem);
    //add sub items
    _lstItems.AddRange(GetTSMItems(_tsmItem));
}  
private IEnumerable<ToolStripMenuItem> GetTSMItems(ToolStripMenuItem _tsmBaseItem)
{
    foreach (ToolStripMenuItem _tsmItem in _tsmBaseItem.DropDownItems)
    {
        if (_tsmItem.HasDropDownItems)
        {
            foreach (ToolStripMenuItem _tsmSubItem in GetItems(_tsmItem))
                yield return _tsmSubItem;
        }
        yield return _tsmItem;
    }
}

Ref - http://stackoverflow.com/
0
 

Author Closing Comment

by:ajaymaster1558
ID: 40473437
thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now