Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Recent Fie List

Recent Fie List

Recent Fie List

I am working on a program where I want to add a recent file list, much like MS Office.

I have added a menustrip with a ToolStripMenuItem. I have been able to add a list of recent files to the ToolStripMenuItem. However I am not able to open recent files when clicking on them in the ToolStripMenuItem.

Doing research I learned that I need to use Add Handler, but have not found a easily understandable explanation on how to do this.

Is using Add Handler the best and easiest way to do this, if so how?
Is their a better way to do this, if so how?

Anybody have a good explanation or know of a site that explains it well.

Thank You

RE: Recent Fie List

First, create the handler code for the ToolStripMenuItem's Click event:

Say it's named RecentFilesMenu, so use
Private Sub RecentFilesMenu_Click(Sender as Object, e as EventArgs)
'code here
End Sub

Then, in the form's Load event, put the AddHandler code:

AddHandler ToolStripMenuItem1.Click, AddressOf RecentFilesMenu_Click

Now when you click on the ToolStripMenuItem, the code in RecentFilesMenu_Click will run.

Also, if you're adding a ToolStripMenuItem for each recent file, then you're probably defining and adding them at runtime. To make the ToolStripMenuItem work with the event handler, it has to be defined as WithEvents, like so:

Dim WithEvents ToolStripMenuItem1 As ToolStripMenuItem

If you don't Dim WithEvents, the AddHandler code will fail.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

RE: Recent Fie List

I got it working using code from another source.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close