The simple but usefull AddToEnd listbox extension for C# and VB.NET.

Sample C#

public static void AddToEnd(this ListBox listbox, object data)
{
	listbox.Items.Add(data);
	listbox.TopIndex = listbox.Items.Count - 1;
	listbox.ClearSelected();
}

Sample VB.NET

<System.Runtime.CompilerServices.Extension> _
Public Shared Sub AddToEnd(listbox As ListBox, data As Object)
	listbox.Items.Add(data)
	listbox.TopIndex = listbox.Items.Count - 1
	listbox.ClearSelected()
End Sub

One thought on “AddToEnd listbox extension for C# and VB.NET”

Leave a Reply