从DataGrid SelectionChanged获取选定的DataGridRow [英] Get selected DataGridRow from DataGrid SelectionChanged
本文介绍了从DataGrid SelectionChanged获取选定的DataGridRow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在DataGrid中获取对所选DataGridRow的引用。 我可以获得selectedindex,但我不知道在哪里使用它获得对所选行的引用。
Craig Dahlinger - 高级软件开发人员
解决方案
VB:
私有 Sub CollectionName_SelectionChanged()
Dim selectedItem = 我 .EntitiesName.SelectedItem
如果 (selectedItem Nothing ) 然后 返回
结束 Sub
C#:
private void CollectionName_SelectionChanged()
{
var selectedItem = this.EntitiesName.SelectedItem;
if(selectedItem == null){return;}
}
Is there a way to get a reference to the selected DataGridRow within the DataGrid. I can get the selectedindex, but I am not sure where to use it get a reference to the selected row.
Craig Dahlinger - Senior Software Developer
解决方案
VB:
Private Sub CollectionName_SelectionChanged() Dim selectedItem = Me.EntitiesName.SelectedItem If (selectedItem Is Nothing) Then Return End Sub
C#:
private void CollectionName_SelectionChanged() { var selectedItem = this.EntitiesName.SelectedItem; if (selectedItem == null) { return; } }
这篇关于从DataGrid SelectionChanged获取选定的DataGridRow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文