ListBox.ColumnWidth プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As ListBox Dim value As Integer value = instance.ColumnWidth instance.ColumnWidth = value
/** @property */ public int get_ColumnWidth () /** @property */ public void set_ColumnWidth (int value)
コントロール内の各列の幅 (ピクセル単位)。既定値は 0 です。


値として 0 を設定すると、各列には既定の幅が割り当てられます。ListBox が複数列の ListBox である場合、このプロパティはリスト内の各列の現在の幅を返します。このプロパティを使用すると、複数列の ListBox 内の各列に項目を適切に表示できます。

ColumnWidth プロパティと MultiColumn プロパティを使用して、複数の列に項目を表示する ListBox コントロールを作成する方法を次のコード例に示します。この例では、listBox1 という名前の ListBox コントロールがフォームに追加されている必要があります。
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からListBox.ColumnWidth プロパティを検索する場合は、下記のリンクをクリックしてください。

- ListBox.ColumnWidth プロパティのページへのリンク