ListBox.HorizontalExtent プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ListBox.HorizontalExtent プロパティの意味・解説 

ListBox.HorizontalExtent プロパティ

ListBoxスクロール バースクロールできる幅を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

<LocalizableAttribute(True)> _
Public Property HorizontalExtent As
 Integer
Dim instance As ListBox
Dim value As Integer

value = instance.HorizontalExtent

instance.HorizontalExtent = value
[LocalizableAttribute(true)] 
public int HorizontalExtent { get;
 set; }
[LocalizableAttribute(true)] 
public:
property int HorizontalExtent {
    int get ();
    void set (int value);
}
/** @property */
public int get_HorizontalExtent ()

/** @property */
public void set_HorizontalExtent (int
 value)
public function get HorizontalExtent
 () : int

public function set HorizontalExtent
 (value : int)

プロパティ
スクロール バーコントロールスクロールできる幅 (ピクセル単位)。既定値は 0 です。

解説解説

このプロパティは、HorizontalScrollbar プロパティtrue設定されている場合にだけ有効な値を報告しますListBox の幅がこのプロパティの値よりも小さ場合は、スクロール バー使用して ListBox 内の項目を平方向にスクロールできますListBox の幅がこの値以上の場合は、スクロール バー表示されません。このプロパティの値は、ListBox によって動的に更新されません。このプロパティは、ListBox の項目がオーナー描画である場合役立ちます。たとえば、ListBoxオーナー描画項目の幅が 200 ピクセルで、ListBox の幅が 60 ピクセル場合は、コントロールスクロールして項目の右端表示できるようにするためには、HorizontalExtent プロパティ200設定する必要があります

使用例使用例

HorizontalScrollbar プロパティHorizontalExtent プロパティ使用してListBox コントロールすべての項目のテキスト表示するためのスクロール バー表示する方法次のコード例示しますまた、この例では、IntegralHeight プロパティ使用してListBox コントロールサイズかかわらず、項目の全部表示されることを保証します。この例では、listBox1 という名前の ListBox コントロールフォーム追加されている必要があります

Private Sub DisplayHScroll()
   ' Make no partial items are displayed vertically.
   listBox1.IntegralHeight = True
   Dim x As Integer

   ' Add items that are wide to the ListBox.
   For x = 0 To 10
      listBox1.Items.Add("Item  " + x.ToString() +
 " is a very large value that requires scroll bars")
   Next x

   ' Display a horizontal scroll bar.
   listBox1.HorizontalScrollbar = True

   ' Create a Graphics object to use when determining the size of the
 largest item in the ListBox.
   Dim g As System.Drawing.Graphics = listBox1.CreateGraphics()


   ' Determine the size for HorizontalExtent using the MeasureString
 method using the last item in the list.
   Dim hzSize As Integer
 = g.MeasureString(listBox1.Items(listBox1.Items.Count - 1).ToString(), listBox1.Font).Width
   ' Set the HorizontalExtent property.
   listBox1.HorizontalExtent = hzSize
End Sub
private void DisplayHScroll()
{
   // Make no partial items are displayed vertically.
   listBox1.IntegralHeight = true;

   // Add items that are wide to the ListBox.
   for (int x = 0; x < 10; x++)
   {
      listBox1.Items.Add("Item  " + x.ToString() + " is a very large
 value that requires scroll bars");
   }

   // Display a horizontal scroll bar.
   listBox1.HorizontalScrollbar = true;

   // Create a Graphics object to use when determining the size of the
 largest item in the ListBox.
   Graphics g = listBox1.CreateGraphics();

   // Determine the size for HorizontalExtent using the MeasureString
 method using the last item in the list.
   int hzSize = (int) g.MeasureString(listBox1.Items[listBox1.Items.Count
 -1].ToString(),listBox1.Font).Width;
   // Set the HorizontalExtent property.
   listBox1.HorizontalExtent = hzSize;
}
private:
   void DisplayHScroll()
   {
      // Make no partial items are displayed vertically.
      listBox1->IntegralHeight = true;

      // Add items that are wide to the ListBox.
      for ( int x = 0; x < 10; x++ )
      {
         listBox1->Items->Add( String::Format( "Item {0} is a very large
 value that requires scroll bars", x ) );

      }

      // Display a horizontal scroll bar.
      listBox1->HorizontalScrollbar = true;

      // Create a Graphics object to use when determining the size of the
 largest item in the ListBox.
      Graphics^ g = listBox1->CreateGraphics();

      // Determine the size for HorizontalExtent using the MeasureString
 method using the last item in the list.
      int hzSize = (int)g->MeasureString(
 dynamic_cast<String^>(listBox1->Items[ listBox1->Items->Count -
 1 ]), listBox1->Font ).Width;

      // Set the HorizontalExtent property.
      listBox1->HorizontalExtent = hzSize;
   }
private void DisplayHScroll()
{
    // Make no partial items are displayed vertically.
    listBox1.set_IntegralHeight(true);

    // Add items that are wide to the ListBox.
    for (int x = 0; x < 10; x++) {
        listBox1.get_Items().Add("Item  " + Convert.ToString(x) 
            + " is a very large value that requires scroll bars");
    }

    // Display a horizontal scroll bar.
    listBox1.set_HorizontalScrollbar(true);

    // Create a Graphics object to use when determining the size 
    // of the largest item in the ListBox.
    Graphics g = listBox1.CreateGraphics();

    // Determine the size for HorizontalExtent using the MeasureString
 
    // method using the last item in the list.
    int hzSize = (int)(g.MeasureString(listBox1.get_Items().
        get_Item(listBox1.get_Items().get_Count() - 1).ToString(), 
        listBox1.get_Font()).get_Width());

    // Set the HorizontalExtent property.
    listBox1.set_HorizontalExtent(hzSize);
} //DisplayHScroll
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からListBox.HorizontalExtent プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からListBox.HorizontalExtent プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からListBox.HorizontalExtent プロパティを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ListBox.HorizontalExtent プロパティ」の関連用語

ListBox.HorizontalExtent プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ListBox.HorizontalExtent プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS