Aracılığıyla paylaş


ListBox.PreferredHeight Özellik

Tanım

içindeki ListBoxtüm öğelerin birleşik yüksekliğini alır.

public:
 property int PreferredHeight { int get(); };
[System.ComponentModel.Browsable(false)]
public int PreferredHeight { get; }
[<System.ComponentModel.Browsable(false)>]
member this.PreferredHeight : int
Public ReadOnly Property PreferredHeight As Integer

Özellik Değeri

Denetimdeki tüm öğelerin piksel cinsinden birleşik yüksekliği.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, içindeki tüm öğeleri ListBox kaydırma çubukları kullanılmadan görüntülemek için özelliğinin PreferredHeight değerini temel alarak özelliğinin nasıl ayarlandığını SizeListBox gösterir. Bu örnek, adlı listBox1bir ListBox denetimin forma eklenmesini gerektirir.

private:
   void SizeMyListBox()
   {
      // Add items to the ListBox.
      for ( int x = 0; x < 20; x++ )
      {
         listBox1->Items->Add( String::Format( "Item {0}", x ) );
      }
      listBox1->Height = listBox1->PreferredHeight;
   }
private void SizeMyListBox()
{
   // Add items to the ListBox.
   for(int x = 0; x < 20; x++)
   {
      listBox1.Items.Add("Item " + x.ToString());
   }
   // Set the height of the ListBox to the preferred height to display all items.
   listBox1.Height = listBox1.PreferredHeight;
}
Private Sub SizeMyListBox()
   ' Add items to the ListBox.
   Dim x As Integer
   For x = 0 To 19
      listBox1.Items.Add(("Item " + x.ToString()))
   Next x
   ' Set the height of the ListBox to the preferred height to display all items.
   listBox1.Height = listBox1.PreferredHeight
End Sub

Açıklamalar

Bu özellik, listedeki kullanılabilir her öğeyi görüntülemek ve dikey kaydırma çubuklarının ListBox görüntülenmesini önlemek için boyutunun gerektiği yüksekliği belirlemenizi sağlar. içindeki ListBox öğe miktarı büyükse, özelliğin değerini PreferredHeight kullanarak denetimi boyutlandırmak, öğesinin formun veya kapsayıcının istemci alanının dışında boyutlandırılmasına ListBox neden ListBox olabilir.

Şunlara uygulanır

Ayrıca bkz.