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.
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
Private Sub Form_Load(ByVal sender As Object,_
ByVal e As System.EventArgs) Handles MyBase.Load
theList = New CjsDen.MruList(mnuFileRecent)
We also need to add code to handle the
MruList's click event:
Public Sub MruFileOpen(ByVal mruPath As String)_
How to Use the MRU List
Now, all we have to do is add file paths to the MRU list:
If you want to save the list, you can access it with any of the following properties:
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.