### Maintain Recent Item List

An example on how to maintain a recent items list using a ComboBox.
The recent items are captured in a textfile, which is loaded when starting the app.
Define Globals
Private cbRecentItems As ComboBox
Private RecentItemsMax as Int = 10
Private RecentItemsFile As String = "RecentItems.txt"
In AppStart add the ComboBox Items from the file
If (File.Exists(File.DirApp, RecentItemsFile)) Then
cbRecentItems.Items.AddAll(File.ReadList(File.DirApp, RecentItemsFile))
If (cbRecentItems.Items.Size > 0) Then cbRecentItems.SelectedIndex = 0
End If
Build a Sub to Update the RecentItems in the ComboxBox and File
`Sub UpdateRecentItems(s As String)
If s.Length = 0 Then Return
Dim i As Int
i = cbRecentItems.Items.IndexOf(s)
If i <> -1 Then Return
cbRecentItems.Items.InsertAt(0, s)
cbRecentItems.SelectedIndex = 0
i = cbRecentItems.Items.Size
If (i > RecentItemsMax) Then cbRecentItems.Items.RemoveAt(i - 1)
File.WriteList(File.DirApp, RecentItemsFile, cbRecentItems.Items)
End Sub`
Handle ComboBox Recent Items Value changed
`Sub cbRecentItems_ValueChanged (Value As Object)
UpdateRecentItems(Value)
End Sub`
`Sub cbRecentItems_SelectedIndexChanged(Index As Int, Value As Object)
Log("RecentItem: " & Value)
End Sub`

Changed: , Category: ComboBox, File: T6C175M1270.htm, ID: 1270