ListBox.IntegralHeight 속성

정의

부분 항목을 표시하지 않도록 컨트롤의 크기를 조정할지를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

Boolean

부분 항목을 표시하지 않도록 컨트롤의 크기를 조정하려면 true이고, 그렇지 않으면 false입니다. 기본값은 true입니다.

예제

다음 코드 예제에서는 컨트롤의 HorizontalScrollbar HorizontalExtent 모든 항목 텍스트를 ListBox 보여 주는 가로 스크롤 막대를 표시 하는 속성을 사용 하는 방법을 보여 줍니다. 또한 이 예제에서는 컨트롤의 크기 ListBox 로 인해 항목이 부분적으로 표시되지 않도록 하기 위해 이 속성을 사용합니다IntegralHeight. 이 예제에서는 명명listBox1ListBox 컨트롤이 양식에 추가되어야 합니다.

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

설명

이 속성을 설정 true하면 컨트롤의 크기가 자동으로 조정되어 항목이 부분적으로 표시되지 않도록 합니다. 양식의 ListBox 공간 요구 사항에 따라 원래 크기를 유지하려면 이 속성을 으로 false설정합니다.

기본적으로 ListBox 크기 및 CheckedListBox 크기는 전체 항목만 표시되도록 합니다. 도킹된 ListBox 영역을 채우거나 CheckedListBox 완전히 채우려면 다음으로 false설정합니다IntegralHeight. 이렇게 하면 컨트롤이 영역을 완전히 채우지만 마지막 항목이 완전히 표시되지는 않습니다.

항목이 ListBox 없으면 이 속성은 영향을 주지 않습니다.

참고

정수 높이는 클라이언트 영역 높이가 ListBox아닌 높이를 기반으로 합니다. 따라서 속성이 IntegralHeight 설정 true되면 스크롤 막대가 표시되는 경우에도 항목이 부분적으로 표시될 수 있습니다.

참고

속성이 DrawMode 설정된 DrawMode.OwnerDrawVariable경우 이 속성은 영향을 주지 않습니다.

적용 대상

추가 정보