MRU List using ToolstripMenuItem???

Troy

Well-known member
Joined
Feb 7, 2005
Messages
153
Programming Experience
10+
MRU List using MenuStrip???

Hello can anyone help give me an example of creating an MRU List using the New 2005 MenuStrip? All of the examples I'm finding on the web and for .Net use MenuItem but the MenuStrip is different, enough so to confuse someone that doesn't know much about MRU lists to begin with.:(
 
Last edited:
MRU and menu is two different things in my mind.

MRU is short for Most Recent Used, and you have to keep track of this when your application accesses files, you could for example make the number of mru as separate application settings or you could use a Queue. Try some to enqueue and dequeue to see how it works.

When you have managed the mru and also chosen the means of storage when application is not running (binary serialization is recommended, very easy) you can add the items in your mru list to menu items and also update this when the mru list changes.

Adding a menuitem could be done like this:
VB.NET:
[SIZE=2]FilesToolStripMenuItem.DropDownItems.Add(str, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]AddressOf[/COLOR][/SIZE][SIZE=2] MenuItem_Click)[/SIZE]
 
Thanks John I managed to get it all working perfectly.

I'm old school who's been trying to catch up since Visual Basic 3.0 then 4.0 , skipped 5 but went to 6.0 then .Net now finally 2005 and Since 6.0 things really sent me into left field. I thought I had it all figured out then but now it's hard to unlearn and relearn.

My next thing is calling my CHM Help file from My program. Yes even that is done differently since 6.0:(

When will the Madness end!:eek:
 
You can start any process or file from default handler with the Process class, code:
VB.NET:
Dim helppath As String = IO.Path.Combine(Application.StartupPath, "myhelp.chm")
Process.Start(helppath)
 
I wrote some code that implement the ideas mentioned earlier, I attach the class and demo form here so you can compare. There is not much code and it's hopefully easy to read without any code comments.
 

Attachments

  • vbnet20-mru.zip
    14.6 KB · Views: 40
:D Thanks John Your examples helped me tremendously! After re-evaluation though I decided to still have only one tree entry for my customers and make multiple sales records selectable after they choose the customer record.
 
Back
Top