ListBox.IntegralHeight Özellik

Tanım

Kısmi öğelerin gösterilmesini önlemek için denetimin yeniden boyutlandırılıp boyutlandırılmayacağını belirten bir değer alır veya ayarlar.

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

Özellik Değeri

true Denetimin kısmi öğeleri görüntülememesi için yeniden boyutlandırılıp boyutlandırılmaması; aksi takdirde , false. Varsayılan değer: true.

Örnekler

Aşağıdaki kod örneği, denetimdeki HorizontalScrollbar tüm öğe metnini ListBox gösteren yatay bir kaydırma çubuğu görüntülemek için ve HorizontalExtent özelliklerinin nasıl kullanılacağını gösterir. Örnek ayrıca denetimin IntegralHeight boyutu ListBox nedeniyle öğelerin kısmen görüntülenmemesini sağlamak için özelliğini kullanır. Bu örnek, forma adlı listBox1bir ListBox denetimin eklenmesini gerektirir.

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

Açıklamalar

Bu özellik olarak trueayarlandığında, bir öğenin kısmen görüntülenmediğinden emin olmak için denetim otomatik olarak yeniden boyutlandırılır. Formunuzun alan gereksinimlerine göre özgün boyutunu ListBox korumak istiyorsanız, bu özelliği olarak falseayarlayın.

Varsayılan olarak ListBox ve CheckedListBox boyutları yalnızca tüm öğeleri gösterecek şekildedir. veya öğesinin ListBox yerleşik bir alanı tamamen doldurmasını istiyorsanız olarak ayarlayınfalseIntegralHeight.CheckedListBox Bu, denetimin alanı tamamen doldurmasına neden olur, ancak son öğe tam olarak görüntülenmez.

ListBox herhangi bir öğe içermiyorsa, bu özelliğin hiçbir etkisi yoktur.

Not

İntegral yükseklik, istemci alanı yüksekliği ListBoxyerine yüksekliğini temel alır. Sonuç olarak, IntegralHeight özelliği ayarlandığında truekaydırma çubukları görüntüleniyorsa öğeler kısmen gösterilebilir.

Not

DrawMode Özelliği olarak ayarlanırsaDrawMode.OwnerDrawVariable, bu özelliğin hiçbir etkisi olmaz.

Şunlara uygulanır

Ayrıca bkz.