Most Recently Used for objects on a form

Probably other ways of doing this. However this is my quickly devised method. Using a MRUToolStripDropDownButton.
Need to call MRUAdd after loading an object

Private mruList As IList(Of T)

Private Sub MRUAdd()
If mruList.Contains(Me.cPadMain) Then
End If

If mruList.Where(Function(m) m.ID = cPadMain.ID).Count = 0 Then
mruList.Insert(0, Me.cPadMain)
End If

End Sub

Private Sub MRUDisplay()

Dim MRU As IEnumerable(Of PadMain) = From pm In mruList Order By pm.PadMaterial Descending
For Each pm As PadMain In MRU
Dim tsi As New ToolStripMenuItem
tsi.Tag = pm.ID
tsi.Text = pm.Pad + " in " + pm.Material.Material + " " + pm.ID.ToString
MRUToolStripDropDownButton.DropDownItems.Insert(0, tsi)
If MRUToolStripDropDownButton.DropDownItems.Count > 10 Then
Exit For
End If

End Sub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: