MultiColumn Property

ListBox.MultiColumn Property


Gets or sets a value indicating whether the ListBox supports multiple columns.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool MultiColumn { get; set; }

Property Value

Type: System.Boolean

true if the ListBox supports multiple columns; otherwise, false. The default is false.

Exception Condition

A multicolumn ListBox cannot have a variable-sized height.

A multicolumn ListBox places items into as many columns as are needed to make vertical scrolling unnecessary. The user can use the keyboard to navigate to columns that are not currently visible. Set the HorizontalScrollbar property to true to display a horizontal scroll bar that enables the user to scroll to columns that are not currently shown in the visible region of the ListBox. The value of the ColumnWidth property determines the width of each column.

The following code example demonstrates a simple two-column ListBox.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form
    private ListBox listBox1;

    public Form1()
    static void Main()
        Application.Run(new Form1());

    private void InitializeComponent()
        this.listBox1 = new System.Windows.Forms.ListBox();
        // listBox1
        this.listBox1.FormattingEnabled = true;
        this.listBox1.HorizontalScrollbar = true;
        this.listBox1.Items.AddRange(new object[] {
            "Item 1, column 1",
            "Item 2, column 1",
            "Item 3, column 1",
            "Item 4, column 1",
            "Item 5, column 1",
            "Item 1, column 2",
            "Item 2, column 2",
            "Item 3, column 2"});
        this.listBox1.Location = new System.Drawing.Point(0, 0);
        this.listBox1.MultiColumn = true;
        this.listBox1.Name = "listBox1";
        this.listBox1.ScrollAlwaysVisible = true;
        this.listBox1.Size = new System.Drawing.Size(120, 95);
        this.listBox1.TabIndex = 0;
        this.listBox1.ColumnWidth = 85;
        // Form1
        this.ClientSize = new System.Drawing.Size(292, 273);
        this.Name = "Form1";


.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft