How to Use Columns in a Listbox

Listboxes are form elements that display an array of options for the user. The most prominent use for a listbox is its ability to allow users to select multiple options. Listboxes also have the ability to have multiple columns. Once the multicolumns are set, the programmer populates the list of items. These items are then displayed to the user. This action can be accomplished in C# using Visual Studio.

Instructions

    • 1

      Open Visual Studio and create a new HTML page. When the page opens, the workspace shows a toolbox to the left of the screen. Drag and drop the icon labeled "Listbox" from the toolbox to the web page in the workspace. This creates a basic listbox on the web page with only one column.

    • 2

      Click the image of the listbox on the screen. On the right of the window, there is a "Properties" pane. Scroll down this pane and set the "Multicolumn" value to true. This allows multiple columns within the listbox to propagate values.

    • 3

      Double-click the web page in the solution window. The code window will appear where you can enter the data into the listbox.

    • 4

      Enter the information you want to propagate into the listbox control on the form. Below is the code to enter items:
      this.listBox1.Items.AddRange(new object[] {"Item 1, column 1","Item 2, column 2","Item 3, column 3"});
      The items and columns indicate the data to propagate into each column. The first "Item" data is the labeled information shown in the listbox. The column indicates the column that will show the information.

    • 5

      Press the "Ctrl" and the "S" button on the keyboard. This saves the page. Open the page using your browser. This will display the listbox and allow you to troubleshoot and test the listbox.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured