Creating a Recent Files List

  • Thread starter Thread starter Anil Gupte
  • Start date Start date
A

Anil Gupte

I got as far as this;
Private Sub PopulateRecentFilesList()

For Each item As String In L3G.RecentFilesList

mnuTopFile.MenuItems.Add(item, New EventHandler(AddressOf menuItem2_Click))

Next

End Sub

But how do I pass the actual file name to the event handler? And also, am I
doing the right thing by assigning the same event handler?

Finally, this is going in a main menu. I could not figure out how to do
this in a sub menu (like a flyout).
 
Anil Gupte said:
I got as far as this;
Private Sub PopulateRecentFilesList()

For Each item As String In L3G.RecentFilesList

mnuTopFile.MenuItems.Add(item, New EventHandler(AddressOf
menuItem2_Click))

Next

End Sub

But how do I pass the actual file name to the event handler?

Is that different from the menu item text ? If so you could probably set
the menuitem's tag property.
And also, am I doing the right thing by assigning the same event handler?

Yes


Finally, this is going in a main menu. I could not figure out how to do
this in a sub menu (like a flyout).

You do it basically the same, adding to the menuitem's menuitems properties
you just need to be sure you do so before the menu is rendered.
 
I got as far as this;
Private Sub PopulateRecentFilesList()

For Each item As String In L3G.RecentFilesList

mnuTopFile.MenuItems.Add(item, New EventHandler(AddressOf menuItem2_Click))

Next

End Sub

But how do I pass the actual file name to the event handler?  And also, am I
doing the right thing by assigning the same event handler?

Finally, this is going in a main menu.  I could not figure out how to do
this in a sub menu (like a flyout).

Instead of trying to re-invent the wheel, I used the code at:

http://www.codeproject.com/KB/cs/mru.aspx

To add this functionality to a VB.NET project I was working on
recently. I know it is in C#, but it was pretty easy to convert to VB.
 
Back
Top