ListBox.GetItemRectangle(Int32) 方法

定义

返回 ListBox 中的项的边框。Returns the bounding rectangle for an item in the ListBox.

public:
 System::Drawing::Rectangle GetItemRectangle(int index);
public System.Drawing.Rectangle GetItemRectangle (int index);
member this.GetItemRectangle : int -> System.Drawing.Rectangle
Public Function GetItemRectangle (index As Integer) As Rectangle

参数

index
Int32

要返回其边框的项的从零开始的索引。The zero-based index of item whose bounding rectangle you want to return.

返回

Rectangle,表示指定项的边框。A Rectangle that represents the bounding rectangle for the specified item.

异常

index 参数或者小于零,或者大于或等于 Count 类的 ListBox.ObjectCollection 属性的值。The index parameter is less than zero or greater than or equal to the value of the Count property of the ListBox.ObjectCollection class.

注解

如果 index 参数中指定的项不可见,则此方法返回的矩形将位于控件的可见部分之外。If the item specified in the index parameter is not visible, the rectangle returned by this method will be outside the visible portion of the control. 您可以使用此方法来确定项在列表中的大小和位置。You can use this method to determine the size and position of an item within the list. 若要获取项的高度(特别是可变高度所有者描述的列表项),可以使用 GetItemHeight 方法。To get the height of an item, especially a variable-height owner drawn list item, you can use the GetItemHeight method.

适用于