IGridProvider.GetItem(Int32, Int32) 方法


擷取指定儲存格的使用者介面自動化提供者。Retrieves the UI Automation provider for the specified cell.

 System::Windows::Automation::Provider::IRawElementProviderSimple ^ GetItem(int row, int column);
public System.Windows.Automation.Provider.IRawElementProviderSimple GetItem (int row, int column);
abstract member GetItem : int * int -> System.Windows.Automation.Provider.IRawElementProviderSimple
Public Function GetItem (row As Integer, column As Integer) As IRawElementProviderSimple



重要的資料列序號。The ordinal number of the row of interest.


重要的資料行序號。The ordinal number of the column of interest.



指定儲存格的使用者介面自動化提供者。The UI Automation provider for the specified cell.


下列程式碼是此方法的範例執行,這個方法會傳回代表指定位置之專案的物件。The following code is an example implementation of this method that returns an object representing the item at the specified location.

IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
    return (IRawElementProviderSimple)gridItems[row, column];
Private Function GetItem(ByVal row As Integer, ByVal column As Integer) As IRawElementProviderSimple Implements IGridProvider.GetItem
    Return CType(gridItems(row, column), IRawElementProviderSimple)
End Function


  • 格線座標是以零為基礎,具有左上角 (或右上角儲存格,視地區設定) 具有座標 (0,0) 。Grid coordinates are zero-based with the upper left (or upper right cell depending on locale) having coordinates (0,0).

  • 如果資料格是空的,則仍然必須傳回消費者介面自動化提供者,才能支援 ContainingGrid 該資料格的屬性。If a cell is empty a UI Automation provider must still be returned in order to support the ContainingGrid property for that cell. 當方格中的子項目版面配置類似于不完全的陣列時,就可能發生這種情況。This is possible when the layout of child elements in the grid is similar to a ragged array.

顯示不完全配置的 Windows 檔案總管檢視。Windows Explorer view showing ragged layout.
座標是空的方格控制項範例Example of a Grid Control with Empty Coordinates

  • 隱藏的資料列和資料行(視提供者的執行而定)可以載入消費者介面自動化樹狀結構中,因此會反映在 RowCountColumnCount 屬性中。Hidden rows and columns, depending on the provider implementation, can be loaded in the UI Automation tree and will therefore be reflected in the RowCount and ColumnCount properties. 如果隱藏的資料列和資料行尚未載入,就不應加以計算。If the hidden rows and columns have not yet been loaded they should not be counted.