By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,484 Members | 1,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,484 IT Pros & Developers. It's quick & easy.

FindFormForMenuItem

P: n/a
I can't figure out how to find the Form for a MenuItem is on using a reference to the
MenuItem only? I'm looking for something like the FindForm method for controls. I
finally figured out how do do it for components (see below), but I can't figure out
how to do something similar for menu items. Any ideas?

Thanks in Advance - JackRazz
Public Shared Function FindFormForComponent(ByVal component As
System.ComponentModel.Component) As Form
Dim i As Integer
Dim container As System.ComponentModel.IContainer = component.Site.Container
Dim components As System.ComponentModel.ComponentCollection =
component.Site.Container.Components
For i = 0 To components.Count - 1
component = CType(components.Item(i), Component)
Dim parentForm As Form
If TypeOf component Is Form Then
Return CType(component, Form)
End If
Next
End Function

Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"JackRazz" <Ja******@NotValid.com> schrieb
I can't figure out how to find the Form for a MenuItem is on using a
reference to the MenuItem only? I'm looking for something like the
FindForm method for controls. I finally figured out how do do it for
components (see below), but I can't figure out how to do something
similar for menu items. Any ideas?

AFAIS it is not possible. Why do you need it? Maybe you could raise an event
handled by the Form instead? BTW, a menuItem *is* a component.
Please post only to the appropriate groups next time.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
* "JackRazz" <Ja******@NotValid.com> scripsit:
I can't figure out how to find the Form for a MenuItem is on using a reference to the
MenuItem only?


Try this: 'MenuItem1.GetMainMenu().GetForm()'.

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

P: n/a
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb
* "JackRazz" <Ja******@NotValid.com> scripsit:
I can't figure out how to find the Form for a MenuItem is on using
a reference to the MenuItem only?


Try this: 'MenuItem1.GetMainMenu().GetForm()'.


*argh*

was seraching the props only...
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

P: n/a
* "Armin Zingler" <az*******@freenet.de> scripsit:
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb
* "JackRazz" <Ja******@NotValid.com> scripsit:
I can't figure out how to find the Form for a MenuItem is on using
a reference to the MenuItem only?


Try this: 'MenuItem1.GetMainMenu().GetForm()'.


*argh*

was seraching the props only...


I looked for 'FindForm' on the 'MainMenu' and I didn't find it. Then I
scrolled through the list and saw 'GetForm'.

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

P: n/a
Thats the ticket. It turned out to be quite simple. Thanks for the answer.

Regards - JackRazz

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...
| * "JackRazz" <Ja******@NotValid.com> scripsit:
| > I can't figure out how to find the Form for a MenuItem is on using a reference to
the
| > MenuItem only?
|
| Try this: 'MenuItem1.GetMainMenu().GetForm()'.
|
| --
| Herfried K. Wagner [MVP]
| <URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

P: n/a
* "JackRazz" <Ja******@NotValid.com> scripsit:
Thats the ticket. It turned out to be quite simple. Thanks for the answer.


Thanks for confirming that it worked :-).

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

P: n/a

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...
| * "JackRazz" <Ja******@NotValid.com> scripsit:
| > Thats the ticket. It turned out to be quite simple. Thanks for the answer.
|
| Thanks for confirming that it worked :-).
|
| --
| Herfried K. Wagner [MVP]
| <URL:http://dotnet.mvps.org/>
Nov 20 '05 #8

P: n/a
Ok, case closed.

JackRazz

Dim s As String = MainMenu1.GetForm.Name


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...
| * "JackRazz" <Ja******@NotValid.com> scripsit:
| > Thats the ticket. It turned out to be quite simple. Thanks for the answer.
|
| Thanks for confirming that it worked :-).
|
| --
| Herfried K. Wagner [MVP]
| <URL:http://dotnet.mvps.org/>
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.