![]() ![]() ' Set the ListBox to display items in multiple columns. ![]() ' Set the size and location of the ListBox. Private Sub button1_Click(sender As Object, e As System.EventArgs) Allow the ListBox to repaint and display the new items. ListBox1.SelectionMode = SelectionMode.MultiExtended Private void button1_Click(object sender, System.EventArgs e) ![]() System::Diagnostics::Debug::WriteLine( listBox1->SelectedIndices ) Display the index of the first selected item in the ListBox. System::Diagnostics::Debug::WriteLine( listBox1->SelectedItems ) Display the second selected item in the ListBox to the console. Loop through and add 50 items to the ListBox.įor ( int x = 1 x Items->Add( String::Format( "Item ", x ) ) Shutdown the painting of the ListBox as items are added. ListBox1->SelectionMode = SelectionMode::MultiExtended Set the selection mode to multiple and extended. Set the ListBox to display items in multiple columns. ListBox1->Location = System::Drawing::Point( 10, 10 ) Set the size and location of the ListBox. void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) This example requires that the code is located in and called from a Form. The code then displays values from the ListBox.SelectedObjectCollection collection, through the SelectedItems property, and the ListBox.SelectedIndexCollection, through the SelectedIndices property. The code for the example adds 50 items to the ListBox using the Add method of the ListBox.ObjectCollection class and then selects three items from the list using the SetSelected method. The following code example demonstrates how to create a ListBox control that displays multiple items in columns and can have more than one item selected in the control's list. Public class ListBox : type ListBox = classÄefaultBindingPropertyAttribute ClassInterfaceAttribute ComVisibleAttribute Examples In this article public ref class ListBox : System::Windows::Forms::ListControl public class ListBox : Represents a Windows control to display a list of items. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |