Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
需要根据当前选中的行做一些逻辑。在我做这样的事情之前是 WPF 的新手;
int i myDataGridView.CurrentCell.RowIndex
现在不可用,获得选定行的最佳方法是什么?
使用DataGrid.SelectedItem财产。SelectionMode如果是,它会给出 DataGrid 上的选定项Single。DataGrid.SelectedItems如果 SelectionMode 是Extended或 Multiple , Else给出多重选择
DataGrid.SelectedItem
SelectionMode
Single
DataGrid.SelectedItems
Extended
尝试这个:
SomeObject someObject = (SomeObject)myDataGridView.SelectedItem