Solved

how can i convert it in C#.net window application ??

Posted on 2011-03-08
5
353 Views
Last Modified: 2012-05-11
currently i am creating dynamic menu in my application , for this i want to convert list of toolstripmenuitem into toolstripitemcollections , but how can i do this ??

please refer the below code ..
List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();

Open in new window


now i want to convert above list of toolstripmenuitem in to toolstripitemcollections , but how can i do this ??
0
Comment
Question by:Parth48
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 35068582
Not sure I follow what it is you are after, can you explain in some more detail please about what you hope to achieve?
0
 
LVL 5

Expert Comment

by:mayankagarwal
ID: 35068589
0
 

Author Comment

by:Parth48
ID: 35068639
but how can i convert it into toolstripitemcollections ??
0
 

Author Comment

by:Parth48
ID: 35068663
it's actually needed when u add items to the menustrip ...

please refer the below code ...

MenuStrip menuItems = new MenuStrip();

menuitems.Items.AddRange(toolstripitemcollections);

Open in new window


referring above code i have to need toolstripitemcollections class ...

what can i do now ??
0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 35071733
It should be something like this:

List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();
ToolStrip yourToolStrip = new ToolStrip();

//  ... your code to add ToolStripMenuItem's

ToolStripItemCollection stripCol = new ToolStripItemCollection(yourToolStrip, menuItems.ToArray());

// Or, if the ToolStripItemCollection is already created
stripCol.AddRange(menuItems.ToArray());

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.

733 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