Click here to Skip to main content
12,455,073 members (62,305 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

7.6K views
1 download
3 bookmarked
Posted

Recent Items Tool Strip Menu Item

, 8 Nov 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Create menu item that saves recently opened files

Introduction 

This class extends the ToolStripMenuItem control to list recent files and store recently opened files in the registry.

  

Using the code 

  • Add the cs file to your project.
  • Add a menuStrip and a RecentToolStripMenuItem to your project
  • Add an ItemClick event to set what happens when an item in the list is clicked.  
  • Add recentToolStripMenuItem.UpdateList(); after InitializeComponent(); in the function Form1()
  • Use recentToolStripMenuItem.AddRecentItem(pathToFile); anytime you save or open a file to add it to the list. 

You can change the maximum number of items. The default is 5.

recentToolStripMenuItem.MaxItems = 5;

You can change the registry key the recent list is saved in. The default is HKEY_CURRENT_USER\Software\{Application.CompanyName}\{Application.ProductName}\Recent 

recentToolStripMenuItem.Key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("whatever\\key\\you\\want");

Company Name and Product Name can be changed in the solution properties. Click on the button [Assembly Information]

Points of Interest  

If you use AddRecentItem() for a file that is already in the list it automatically moves it to the top of the list.

History 

No updates yet.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

UziTech
United States United States
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
Questionthe sub menu that contain the recent files is disable Pin
Member 1118208528-Nov-15 0:22
memberMember 1118208528-Nov-15 0:22 
AnswerRe: the sub menu that contain the recent files is disable Pin
Member 124987942-May-16 17:12
memberMember 124987942-May-16 17:12 
GeneralRe: the sub menu that contain the recent files is disable Pin
Member 124987942-May-16 17:25
memberMember 124987942-May-16 17:25 
Questioncan we shorten the name of the MRU file Pin
Nazeer Hussain Shaikh3-Mar-15 17:21
memberNazeer Hussain Shaikh3-Mar-15 17:21 
GeneralBest ToolStripMenuItem MRU Utility Pin
Member 113971643-Mar-15 16:58
memberMember 113971643-Mar-15 16:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 8 Nov 2013
Article Copyright 2013 by UziTech
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid