Any way to allow F1 help for menu items in VB.NET?

G

Guest

In VB6, I used a system, which I loved, whereby I assigned a "helpId" to each
menu item; that way, you could rest the cursor on the item (without actually
running it) and then press F1 to get context help with that particular
command.

In VB6 this was easy, since each menu item had a "helpId" property. That
doesn't seem to be the case in VB.NET. Am I wrong about that, or
(alternatively) is there some other way to accomplish this?
 
G

Guest

Cor,

But how can you find out if a user is pointing to a particular menu item
(not selecting it, just resting the cursor on it) -- so that you can display
the correct help topic just be pressing the F1 key? (or alternately, pressing
some other function key, if F1 is dedicated to VbNet's help object)?
--
Thanks.
(e-mail address removed)


Cor Ligthert said:
Bob,

I don't know what you want to do, but every menuItem in Net 2.0 has a tag
item from the type item.
You can in fact millions of fields put in that by creating a class and
instance that as object.

http://msdn2.microsoft.com/en-us/library/system.windows.forms.menu.tag.aspx

In your case it is probably not even needed and can you just put a string in
it.

Cor
 
M

Mike McIntyre

Bob,

If you are using .NET 1.x you provide help trapping the MenuItem Select
event:

Private Sub MenuItem2_Select(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MenuItem2.Select

MessageBox.Show("Found")

End Sub



If you are using .NET 2.0 and the ToolStripMenu you can provide help by
trapping the ToolStripMenuItem MouseEnter event:



Private Sub CutToolStripMenuItem_MouseEnter(ByVal sender As Object, ByVal e
As System.EventArgs) Handles CutToolStripMenuItem.MouseEnter

MessageBox.Show("found")

End Sub
 
G

Guest

Mike,

Thanks for the idea, its a good one (and I'll probably use it sometime --
I've always wanted to have a way to display a one-line help comment in a
status bar at the bottom of a window, when the user moves his mouse onto a
menu item. I don't think I could do that in VB6).

However, that's not what I am trying to do right now. I guess I didn't make
myself clear, because you're the second person to not quite see what I'm
trying to do. I think what I'm trying to do isn't being done by anyone else,
since I thought of it myself and have never seen any programs (other than my
own) that do this.

Here's the thing -- I want to be able to move my mouse over a menu item
(say, by opening the File menu, and moving down to the Exit item on the
dropdown), and then press the F1 key while the "Exit" item is highlighted
(but NOT clicked). In VB6, each menu item had a HelpContextId property, and I
would assign a number to that property of each menu item in the entire menu
system of my program. I would then write a HTML help system, with a help
topic assigned to each menu item (with a number corresponding to the
HelpContextId assigned to the menu item in the program). Then, the User could
highlight a menu item (such as File/Exit) and then -- WITHOUT clicking the
item, ie, not running the command represented by that item -- press F1 and
immediately see context help for that particular menu item. This was a great
way to write an entire HTML help system just by writing a help topic for each
menu item in the program. In fact, I wrote a program to automatically do most
of that. However, there doesn't seem to be any "HelpContextId" type property
for the individual menu items in a VB.NET program.

I don't think I can accomplish the foregoing by, as you suggested,
responding to the event of the User moving the mouse over a menu item. If
that were the case, the User would be getting help (even if he didn't want
it) every time he tried to select a menu item.

After getting your suggesting, I looked through the possible events for the
menu item object (if it IS an "object"), and I didn't seen any event that
would respond to the user pressing a key, whether it be F1 or any other key.
Thus, I don't think using an event to accomplish what I want is going to work.

Someone else responded to my question by suggesting that I use the TAG
property of the menu item. But he didn't explain how to use that to do what
I'm trying to do. I think what I'm trying to do can only be accomplished if
there is some way to allow the user to press a key while a menu item is
highlighted. Even if there was a way to do that, you would still have to know
what menu item was highlighted at that particular time, but I also don't know
how to determine that programatically.

If you have any further thoughts, I'd sure be thankful to hear them.

Thanks.
(e-mail address removed)


Mike McIntyre said:
Bob,

If you are using .NET 1.x you provide help trapping the MenuItem Select
event:

Private Sub MenuItem2_Select(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MenuItem2.Select

MessageBox.Show("Found")

End Sub



If you are using .NET 2.0 and the ToolStripMenu you can provide help by
trapping the ToolStripMenuItem MouseEnter event:



Private Sub CutToolStripMenuItem_MouseEnter(ByVal sender As Object, ByVal e
As System.EventArgs) Handles CutToolStripMenuItem.MouseEnter

MessageBox.Show("found")

End Sub
 

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