ListBox.HorizontalScrollbar 속성

정의

가로 스크롤 막대가 컨트롤에 표시되는지를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

Boolean

컨트롤에 가로 스크롤 막대를 표시하려면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

예제

다음 코드 예제에서는 사용 하는 방법을 보여 줍니다 및 HorizontalExtent 컨트롤의 HorizontalScrollbar 모든 항목 텍스트를 ListBox 표시 하는 가로 스크롤 막대를 표시 하는 속성입니다. 또한 이 예제에서는 컨트롤의 ListBox 크기 때문에 항목이 부분적으로 표시되지 않도록 속성을 사용합니다IntegralHeight. 이 예제에서는 ListBox 이름이 지정된 listBox1컨트롤을 폼에 추가해야 합니다.

private:
   void DisplayHScroll()
   {
      // Make sure no items are displayed partially.
      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 sure no items are displayed partially.
   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 Sub DisplayHScroll()
     ' Make sure no items are displayed partially.
   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

설명

HorizontalScrollbar 속성에 따라 결정 하는지 여부를 ListBox 가로 스크롤을 표시 해야 경우 표시줄 내 항목의 너비는 ListBox 컨트롤의 오른쪽 가장자리를 넘어 확장 합니다. 이 속성을 설정 true하면 스크롤 막대는 항목의 ListBox너비에 따라 자동으로 표시됩니다. 경우는 ListBox 는 소유자가 그린 ListBox, 가로 스크롤 막대를 올바르게 표시 하기 위해 설정 해야 합니다는 HorizontalExtent 속성입니다.

적용 대상

추가 정보