Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

get list of menuStrip in list view

Posted on 2014-04-21
2
Medium Priority
?
285 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

927 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