ListBox.MultiColumn 속성

정의

ListBox에서 여러 열을 지원하는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool MultiColumn { bool get(); void set(bool value); };
public bool MultiColumn { get; set; }
member this.MultiColumn : bool with get, set
Public Property MultiColumn As Boolean

속성 값

Boolean

ListBox에서 여러 열을 지원하면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

예외

여러 열로 구성된 ListBox가 가변 높이를 가질 수 없는 경우

예제

다음 코드 예제에서는 간단한 두 열을 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()
    {
        InitializeComponent();
    }
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

    private void InitializeComponent()
    {
        this.listBox1 = new System.Windows.Forms.ListBox();
        this.SuspendLayout();
        // 
        // 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.Controls.Add(this.listBox1);
        this.Name = "Form1";
        this.ResumeLayout(false);
    }
}
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms

Public Class Form1
   Inherits Form
   Private listBox1 As ListBox
   
   
   Public Sub New()
      InitializeComponent()
   End Sub
   
   <STAThread()>  _
   Shared Sub Main()
      Application.EnableVisualStyles()
      Application.SetCompatibleTextRenderingDefault(False)
      Application.Run(New Form1())
   End Sub
   
   Private Sub InitializeComponent()
      Me.listBox1 = New System.Windows.Forms.ListBox()
      Me.SuspendLayout()
      ' 
      ' listBox1
      ' 
      Me.listBox1.FormattingEnabled = True
      Me.listBox1.HorizontalScrollbar = True
      Me.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"})
      Me.listBox1.Location = New System.Drawing.Point(0, 0)
      Me.listBox1.MultiColumn = True
      Me.listBox1.Name = "listBox1"
      Me.listBox1.ScrollAlwaysVisible = True
      Me.listBox1.Size = New System.Drawing.Size(120, 95)
      Me.listBox1.TabIndex = 0
      Me.listBox1.ColumnWidth = 85
      ' 
      ' Form1
      ' 
      Me.ClientSize = New System.Drawing.Size(292, 273)
      Me.Controls.Add(listBox1)
      Me.Name = "Form1"
      Me.ResumeLayout(False)
   End Sub
End Class

설명

다중 열은 ListBox 세로 스크롤을 불필요하게 만드는 데 필요한 만큼의 열에 항목을 배치합니다. 사용자는 키보드를 사용하여 현재 표시되지 않는 열로 이동할 수 있습니다. HorizontalScrollbar 사용자가 현재 표시되는 영역에 ListBox표시되지 않는 열로 스크롤할 수 있는 가로 스크롤 막대를 표시하도록 속성을 true 설정합니다. 속성 값은 ColumnWidth 각 열의 너비를 결정합니다.

적용 대상

추가 정보