DataGrid.SelectedCells 屬性

定義

取得目前選取之儲存格的清單。

public:
 property System::Collections::Generic::IList<System::Windows::Controls::DataGridCellInfo> ^ SelectedCells { System::Collections::Generic::IList<System::Windows::Controls::DataGridCellInfo> ^ get(); };
public System.Collections.Generic.IList<System.Windows.Controls.DataGridCellInfo> SelectedCells { get; }
member this.SelectedCells : System.Collections.Generic.IList<System.Windows.Controls.DataGridCellInfo>
Public ReadOnly Property SelectedCells As IList(Of DataGridCellInfo)

屬性值

目前選取之儲存格的清單。

備註

的選取模式 DataGrid 有三種。 選取模式是以 屬性設定 SelectionUnitSelectionUnit視 而定, SelectedCellsSelectedItems 將包含下表所定義的選取專案集合。

DataGridSelectionUnit SelectedCells SelectedItems
Cell 選取儲存格的集合 空白
FullRow 所選資料列中儲存格的集合 所選資料列的集合
CellOrRowHeader 選取儲存格的集合,包括選取列中的所有儲存格 選取的資料列集合,如果未選取完整資料列,則為空白

選取儲存格時, DataGridCell.Selected 會引發 事件、將 DataGridCell.IsSelected 屬性設定 true 為 ,並將儲存格新增至 SelectedCells 集合。

選取資料列時, DataGridRow.Selected 會引發 事件、 DataGridRow.IsSelected 將 屬性設定 trueSelectedItems ,並將資料列加入集合中。

當選取範圍變更時,如果新的或舊的選取範圍包含資料列, SelectionChanged 就會引發 和 SelectedCellsChanged 事件。 SelectionChanged如果新的或舊的選取範圍只包含儲存格,則不會引發事件。

適用於