다음을 통해 공유


ListBox.MultiColumn 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Property MultiColumn As Boolean
‘사용 방법
Dim instance As ListBox
Dim value As Boolean

value = instance.MultiColumn

instance.MultiColumn = value
public bool MultiColumn { get; set; }
public:
property bool MultiColumn {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_MultiColumn ()

/** @property */
public void set_MultiColumn (boolean value)
public function get MultiColumn () : boolean

public function set MultiColumn (value : boolean)

속성 값

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

예외

예외 형식 조건

ArgumentException

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

설명

여러 열로 구성된 ListBox는 세로 스크롤이 필요 없도록 필요한 만큼의 여러 열에 항목을 추가합니다. 사용자는 키보드를 사용하여 현재 볼 수 없는 열을 탐색할 수 있습니다. HorizontalScrollbar 속성을 true로 설정하여 ListBox의 볼 수 있는 영역에 현재 표시되지 않은 열로 스크롤할 수 있는 가로 스크롤 막대를 표시합니다. ColumnWidth 속성 값에 따라 각 열의 너비가 결정됩니다.

예제

다음 코드 예제에서는 ColumnWidthMultiColumn 속성을 사용하여 여러 열에 항목을 표시하는 ListBox 컨트롤을 만드는 방법을 보여 줍니다. 이 예제를 실행하려면 이름이 listBox1ListBox 컨트롤이 폼에 추가되어 있어야 합니다.

Private Sub SetupMyMultiColumn()
   Dim x As Integer
   ' Add items to the ListBox.
   For x = 0 To 50
      ListBox1.Items.Add("Items " + x.ToString())
   Next x
   ' Display items in columns.
   ListBox1.MultiColumn = True
   ' Determine the width of the items in the list to get the best column width setting.
   Dim width As Integer = CInt(ListBox1.CreateGraphics().MeasureString(ListBox1.Items(ListBox1.Items.Count - 1).ToString(), _
      ListBox1.Font).Width)
   ' Set the column width based on the width of each item in the list.
   ListBox1.ColumnWidth = width
End Sub
private void SetupMyMultiColumn()
{
   // Add items to the ListBox.
   for (int x = 0; x < 50; x++)
   {
      listBox1.Items.Add("Items " + x.ToString());
   }
   // Display items in columns.
   listBox1.MultiColumn = true;
   // Determine the width of the items in the list to get the best column width setting.
   int width = (int) listBox1.CreateGraphics().MeasureString(listBox1.Items[listBox1.Items.Count -1].ToString(),
      listBox1.Font).Width;
   // Set the column width based on the width of each item in the list.
   listBox1.ColumnWidth = width;
}
private:
   void SetupMyMultiColumn()
   {
      // Add items to the ListBox.
      for ( int x = 0; x < 50; x++ )
      {
         listBox1->Items->Add( String::Format( "Items {0}", x ) );

      }
      listBox1->MultiColumn = true;

      // Determine the width of the items in the list to get the best column width setting.
      int width = (int)listBox1->CreateGraphics()->MeasureString( listBox1->Items[ listBox1->Items->Count - 1 ]->ToString(), listBox1->Font ).Width;

      // Set the column width based on the width of each item in the list.
      listBox1->ColumnWidth = width;
   }
private void SetupMyMultiColumn()
{
    // Add items to the ListBox.
    for (int x = 0; x < 50; x++) {
        listBox1.get_Items().Add("Items " + System.Convert.ToString(x));
    }

    // Display items in columns.
    listBox1.set_MultiColumn(true);

    // Determine the width of the items in the list to get the best column
    // width setting.
    int width = (int)(listBox1.CreateGraphics().MeasureString(listBox1.
        get_Items().get_Item((listBox1.get_Items().get_Count() - 1)).
        ToString(), listBox1.get_Font()).get_Width());

    // Set the column width based on the width of each item in the list.
    listBox1.set_ColumnWidth(width);
} //SetupMyMultiColumn

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

ListBox 클래스
ListBox 멤버
System.Windows.Forms 네임스페이스
ListBox.HorizontalScrollbar 속성
ListBox.ColumnWidth 속성