You can do something like that, if I understand question correctly (if you want to keep last 5 clipboard items programatically):
const int MaxItems = 5;
static readonly List<string> ClipboardData = new List<string>();
public static void SaveClipboard()
{
ClipboardData.Add(Clipboard.GetText());
if (ClipboardData.Count > MaxItems) ClipboardData.RemoveAt(0);
}
// You don't need lines later, I show them just as example
[STAThreadAttribute]
static void Main()
{
for (int i = 0; i < 10; i++)
{
Clipboard.SetText(i.ToString());
SaveClipboard();
}
foreach (var s in ClipboardData)
{
Console.WriteLine(s);
}
Console.ReadLine();
}
If you need @KMan way check this question also: C#/WPF Can I Store more that 1 type in Clipboard?
So you have to call SaveClipboard() after each clipboard modification. All data will be gathered in ClipboardData