Most Recent Used List for WinForms (ToolStripMruList)
ToolStripMruList allow you to add Most Recent Used (MRU) list to your .NET Windows Forms Application in ToolStrip and MenuStrip.
This control is included in WinForms Controls Library.
Features
- Integrated with ToolStripMenu.
- Customize number of files to remember.
- Auto truncate long file name to defined length.
- User define storage location for recent file list.
- Clear Recent File List.
- Remove Invalid Files.
Using ToolStripMruList (Quick Start)
- Reference CodeArtEng.Controls.dll to your project.
- Add "MruList" from drop down in MenuStrip, ContextMenuStrip or ToolStrip designer.
- With “MruList” object selected, configure Text, MruListSize and MaxPathLength properties at your choice
- Subscribe to RecentFileClicked event to get notify when user clicked on
recent file. Selected file can be retrieve from FileName property in RecentFileClickedEventArgs.
- Recent file entry can be added to list using AddRecentFileToMruList(<FileName>). Argument FileName must be complete file path.
- Save MRU List: Recent file list can be retrieve from RecentFileList properties and store to file, registry or application settings when terminating application.
Example: Save to application settings
[C#]
Properties.Settings.Default.MRUList =
string.Join(";", MRUList.RecentFileList);
Properties.Settings.Default.Save();
[VB.NET]
My.Settings.MRUList = String.Join(";", MRUList.RecentFileList)
My.Settings.Save()
- Load MRU List: Read recent file list from external file, registry or application settings and assign to RecentFileList properties when application loaded.
Example: Read recent file list form application settings.
[C#]
MRUList.RecentFileList = Properties.Settings.Default.MRUList.Split(';');
[VB.NET]
MRUList.RecentFileList = My.Settings.MRUList.Split(';');