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ştirilmiş 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, forma adlı listBox1bir ListBox denetimin 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 görüntülenmesini önlemek için boyutu gereken yüksekliği ListBox belirlemenizi sağlar. içindeki ListBox öğe miktarı büyükse, denetimin özelliğinin PreferredHeight değerini kullanarak boyutlandırılması, öğ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.