How to get top controls of the Form programmatically

G

Guest

I need to get the top controls of the form programmatically.

One of the Top control is ContextMenuStrip. But when I use foreac(Control c
in this.Controls), this type of controls are not included.

How can I do this using foreach()
 
M

Marc Gravell

ContextMenuStrip instances do not typically get added to the Controls
collection (although the Form's MenuStrip does); they are instead held
in the "components" collection (using the designer code).
Alternatively, you could look at the ContextMenuStrip property of the
Form and all the sub-controls in turn.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top