ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

AddToEnd

Adds an item to a listbox as the last item, and makes sure it is visible.

Source

public static void AddToEnd( this System.Windows.Forms.ListBox lb, object o )
{
    lb.Items.Add( o );
    lb.TopIndex = lb.Items.Count - 1;
    lb.ClearSelected();
}

Example

ListBox1.AddToEnd( "foo" );
ListBox1.AddToEnd( "bar" );

Author: David Bakin

Submitted on: 8 mrt. 2009

Language: C#

Type: System.Windows.Forms.ListBox

Views: 5645