Click here to Skip to main content
6,292,426 members and growing! (9,915 online)
Email Password   helpLost your password?
Desktop Development » Menus » General     Intermediate

MRU Menu Class

By chad_ross

MRU Menu class is basically an ArrayList that will automatically populate a MenuItem in a MainMenu control. It will display the 5 most recent entries and exposes a Click event for you to respond to. You can also save the list to a file with the provided properties.
VB, Windows, .NET 1.0, Dev
Posted:8 May 2004
Views:34,333
Bookmarked:20 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
9 votes for this article.
Popularity: 3.82 Rating: 4.00 out of 5

1

2
1 vote, 11.1%
3
4 votes, 44.4%
4
4 votes, 44.4%
5

Sample Image - mruDemo.jpg

Introduction

I am currently working on a couple of programs which need a Most Recently Used files list in the MainMenu. Instead of coding this into each application, I decided to create a reusable class to handle this task for me.

Now, after adding the class to my project, all I have to do is add new file paths as needed, and the MruList class adds the appropriate file paths to the MenuItem I specified.

Declarations

The following needs to be declared to initialize the MRU list:

Public WithEvents theList As CjsDen.MruList

We need to add the initialization of the list to the form's load event:

Private Sub Form_Load(ByVal sender As Object,_
         ByVal e As System.EventArgs) Handles MyBase.Load
    'we need to initialize the mrulist in the forms load event

    theList = New CjsDen.MruList(mnuFileRecent)

End Sub

We also need to add code to handle the MruList's click event:

Public Sub MruFileOpen(ByVal mruPath As String)_
                      Handles theList.mru_click
        'Add code to handle here

        'mruPath returns the string of the clicked menuItem

        'no matter which one is clicked

End Sub

How to use the MRU List

Now, all we have to do is add file paths to the MRU list:

theList.AddNewFile("c:\myDocument.txt")

If you want to save the list, you can access it with any of the following properties:

  • MruListArray,
  • MruPath1,
  • MruPath2,
  • MruPath3,
  • MruPath4,
  • MurPath5

Conclusion

This is a very simple way to automate adding a MRU Menu into a number of projects quickly. I have looked this over several ways and have come across no side effects, but if you find anything buggy, let me know.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

chad_ross


Member

Occupation: Web Developer
Location: Canada Canada

Other popular Menus articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralMRU List PinmemberGeorge Hendrickson12:48 11 Nov '07  
GeneralRe: MRU List Pinmemberchad_ross16:09 11 Nov '07  
GeneralRe: MRU List PinmemberDidier Stevens4:05 30 Nov '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 8 May 2004
Editor: Smitha Vijayan
Copyright 2004 by chad_ross
Everything else Copyright © CodeProject, 1999-2009
Web16 | Advertise on the Code Project