ListBox.ItemHeight 属性

定义

获取或设置 ListBox 中项的高度。Gets or sets the height of an item in the ListBox.

public:
 virtual property int ItemHeight { int get(); void set(int value); };
public virtual int ItemHeight { get; set; }
member this.ItemHeight : int with get, set
Public Overridable Property ItemHeight As Integer

属性值

控件中项的高度(以像素为单位)。The height, in pixels, of an item in the control.

异常

ItemHeight 属性被设置为小于 0 或大于 255 像素。The ItemHeight property was set to less than 0 or more than 255 pixels.

注解

DrawMode 属性设置为 DrawMode.OwnerDrawFixed时,所有项都具有相同的高度。When the DrawMode property is set to DrawMode.OwnerDrawFixed, all items have the same height. DrawMode 属性设置为 DrawMode.OwnerDrawVariable时,ItemHeight 属性指定添加到 ListBox中的每一项的高度。When the DrawMode property is set to DrawMode.OwnerDrawVariable, the ItemHeight property specifies the height of each item added to the ListBox. 由于所有者描述列表中的每一项都有不同的高度,因此您可以使用 GetItemHeight 方法来获取 ListBox中特定项的高度。Because each item in an owner-drawn list can have a different height, you can use the GetItemHeight method to get the height of a specific item in the ListBox. 如果对具有可变高度项的 ListBox 使用 ItemHeight 属性,则此属性将返回控件中第一项的高度。If you use the ItemHeight property on a ListBox with items of variable height, this property returns the height of the first item in the control.

ListBox 项的最大高度为255像素。The maximum height of a ListBox item is 255 pixels.

适用于

另请参阅