473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Components on form

With this cycle

For each ctl in Controls
.....
Next

I can see all visual components on a form but I cannot see Menus,
ContextMenus, ToolTips, Timers, ecc.

How could I write a cycle to see these components. Thanks.

W

Nov 20 '05 #1
6 1205
Hi Wally,

The Menus and the Tooltips are no controls in the sence of forms.control
(not derived from)

For a menu you can use by instance this
For Each mn As MenuItem In Me.MainMenu1.MenuItems
'do your stuff
Next

I hope this gives an idea?

Cor


"Wally" <va**********@cambieri.it> schreef in bericht
news:Mf***********************@news4.tin.it...
With this cycle

For each ctl in Controls
.....
Next

I can see all visual components on a form but I cannot see Menus,
ContextMenus, ToolTips, Timers, ecc.

How could I write a cycle to see these components. Thanks.

W

Nov 20 '05 #2
* "Wally" <va**********@cambieri.it> scripsit:
With this cycle

For each ctl in Controls
.....
Next

I can see all visual components on a form but I cannot see Menus,
ContextMenus, ToolTips, Timers, ecc.


Untested:

<URL:http://www.google.de/groups?selm=OY2eI%24%236DHA.360%40TK2MSFTNGP12.phx .gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Hi Wally

Herfried suggestion to use System.Reflexion works
perfectly. I've been using the following procedure to
browse all menus/contextMenus of a form.

Public Sub BrowseMenus(ByVal f As Form)

Dim myForm As Type = f.GetType()

Dim fields As FieldInfo() = myForm.GetFields
(BindingFlags.Instance Or BindingFlags.NonPublic)

For Each field As FieldInfo In fields

If field.FieldType.Name = "ContextMenu" Then
Dim menu As ContextMenu = DirectCast
(field.GetValue(f), ContextMenu)
<code here>
End If

If field.FieldType.Name = "MainMenu" Then
Dim menu As MainMenu = DirectCast
(field.GetValue(f), MainMenu)
<code here>

End If

Next
End Sub

Kind Regards
Jorge
-----Original Message-----
With this cycle

For each ctl in Controls
.....
Next

I can see all visual components on a form but I cannot see Menus,ContextMenus, ToolTips, Timers, ecc.

How could I write a cycle to see these components. Thanks.
W

.

Nov 20 '05 #4
Hi Wally,

To overcome my very simple answer here something more complete sample
(it stays a sample)

\\\
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
testMenu(Me.MainMenu1.MenuItems(0), _
Me.MainMenu1.MenuItems)
testMenu(Me.ContextMenu1.MenuItems(0), _
Me.ContextMenu1.MenuItems)
End Sub
Private Sub testMenu(ByVal mi As MenuItem, _
ByVal mm As Menu.MenuItemCollection)
For Each mi In mm
MessageBox.Show(mi.Text)
testMenu(mi, mi.MenuItems)
Next
End Sub
///

Cor

Nov 20 '05 #5

"Jorge" <an*******@discussions.microsoft.com> ha scritto nel messaggio
news:12*****************************@phx.gbl...
Hi Wally

Herfried suggestion to use System.Reflexion works
perfectly. I've been using the following procedure to
browse all menus/contextMenus of a form.

Public Sub BrowseMenus(ByVal f As Form)

Dim myForm As Type = f.GetType()

Dim fields As FieldInfo() = myForm.GetFields
(BindingFlags.Instance Or BindingFlags.NonPublic)

For Each field As FieldInfo In fields

If field.FieldType.Name = "ContextMenu" Then
Dim menu As ContextMenu = DirectCast
(field.GetValue(f), ContextMenu)
<code here>
End If

If field.FieldType.Name = "MainMenu" Then
Dim menu As MainMenu = DirectCast
(field.GetValue(f), MainMenu)
<code here>

End If

Next
End Sub

Kind Regards
Jorge
-----Original Message-----
With this cycle

For each ctl in Controls
.....
Next

I can see all visual components on a form but I cannot

see Menus,
ContextMenus, ToolTips, Timers, ecc.

How could I write a cycle to see these components.

Thanks.

W

.

Thank you Herfried and Jorge. With your suggestions my program works fine.

W
Nov 20 '05 #6

"Cor Ligthert" <no**********@planet.nl> ha scritto nel messaggio
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Wally,

To overcome my very simple answer here something more complete sample
(it stays a sample)

\\\
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
testMenu(Me.MainMenu1.MenuItems(0), _
Me.MainMenu1.MenuItems)
testMenu(Me.ContextMenu1.MenuItems(0), _
Me.ContextMenu1.MenuItems)
End Sub
Private Sub testMenu(ByVal mi As MenuItem, _
ByVal mm As Menu.MenuItemCollection)
For Each mi In mm
MessageBox.Show(mi.Text)
testMenu(mi, mi.MenuItems)
Next
End Sub
///

Cor


Thanks Core. Herfried and Jorge already answered to my question.

W
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Yasutaka Ito | last post by:
Hi, As you know, all the non-ui components (like Timer control, etc.) that sit on the form are contained in its private variable 'components'. How can I enumerate such components from any form...
3
by: Junkguy | last post by:
Hi, I'm having a problem in Visual Studio in C#, using .NET Framework 1.1 Version 1.1.4322 and Microsoft Development Environment 2003 Version 7.1.3088 I make a form A and subclass it with form...
3
by: sergey | last post by:
Hi, I want show all components names on form when I press button. I wrote this code button's.onclick event: for (int i = 0; i<=this.components.Components.count - 1; i++)...
4
by: kstriyhon | last post by:
i need to manage mouse events in OWC pivot table in a web form not in a windows form and i can not find any information about this topic, the article i found manage events in a pivot table in a...
5
by: Patrick Vanden Driessche | last post by:
Hi All, I'm currently writing an in-house Form validation framework (WinForms) which is based on 'Component'-inheriting object. So basically, I have a small hierarchy. FormValidator +--...
4
by: Charlie | last post by:
I am trying to create dynamic content in a Windows Form using external data to determine UI elements. The code works fine at runtime. I have tried adding code in Sub New, after...
7
by: John | last post by:
I'm trying to use the OWC on my web form and trying to make it look like Excel. I have the box there but no formatting such as headers, bold font, etc. I have the same control on a asp page and I...
2
by: Adam Right | last post by:
Hi, Can i enumarate the windows form's components? I want to list components on the screen. Thanks... (Note: I am using vs2005)
2
by: David Veeneman | last post by:
Is there a way to iterate the components on a form? I need to determine whether an instance of my custom component (a System.ComponentModel component) is present in a form. I have tried...
0
by: tusharkhose | last post by:
Hi, i'm creating an windows application. Here i'm using a call back to function callback() and hence i need it to be static. I want to set some form components in call back(). Please help me....
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.