ListBox.ItemHeight 属性

获取或设置 ListBox 中项的高度。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
<LocalizableAttribute(True)> _
Public Overridable Property ItemHeight As Integer
用法
Dim instance As ListBox
Dim value As Integer

value = instance.ItemHeight

instance.ItemHeight = value
[LocalizableAttribute(true)] 
public virtual int ItemHeight { get; set; }
[LocalizableAttribute(true)] 
public:
virtual property int ItemHeight {
    int get ();
    void set (int value);
}
/** @property */
public int get_ItemHeight ()

/** @property */
public void set_ItemHeight (int value)
public function get ItemHeight () : int

public function set ItemHeight (value : int)

属性值

控件中项的高度(以像素为单位)。

异常

异常类型 条件

ArgumentOutOfRangeException

ItemHeight 属性被设置为小于 0 或大于 255 像素。

备注

DrawMode 属性设置为 DrawMode.OwnerDrawFixed 时,所有项具有相同的高度。当 DrawMode 属性设置为 DrawMode.OwnerDrawVariable 时,ItemHeight 属性指定添加到 ListBox 中的每个项的高度。因为所有者描述的列表中的每个项可具有不同的高度,所以可使用 GetItemHeight 方法获取 ListBox 中特定项的高度。如果对具有可变高度的项的 ListBox 使用 ItemHeight 属性,则此属性返回控件中第一个项的高度。

ListBox 项的最大高度是 255 像素。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ListBox 类
ListBox 成员
System.Windows.Forms 命名空间
GetItemHeight
ListBox.DrawMode 属性
MeasureItem