绑定到Linq查询时获取数据网格选择 [英] Getting datagrid selection when bound to Linq Query

查看:86
本文介绍了绑定到Linq查询时获取数据网格选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到Linq查询的WPF数据网格.第一列是表中的ID.当用户单击数据网格时,我需要能够获取该ID并在程序中的其他表单上进行进一步搜索.我已经在Google上进行了数小时的梳理,并取得了一些进展,但这与我使用Windows窗体和数据集的方式有所不同.疯狂的事情是,如果我在Datagrid的click事件中做这样的事情.....

var mySelection = dgSearch.SelectedItem;

我可以看到整个信息行.但是对于我的一生,我无法遍历这些数据.我认为这是一个iList,但似乎无法将这些数据分解为元素.

I have a WPF datagrid bound to a Linq query. The first column is the id from the table. When a user clicks on the datagrid I need to be able to take that ID and search further on a different form in my program. I have literally combed for hours on Google and made some progress but this is way different from when I was using Windows Forms and Datasets. The crazy thing is if I do something like this in the click event for the Datagrid.....

var mySelection = dgSearch.SelectedItem;

I can see the entire row of information. But for the life of me I cannot iterate through this data. I think it is an iList but I cannot seem to break that data down into elements.

推荐答案

我有一个绑定到Linq查询的WPF数据网格.第一列是表中的ID.当用户单击数据网格时,我需要能够获取该ID并在程序中的其他表单上进行进一步搜索.我已经在Google上进行了数小时的梳理,并取得了一些进展,但这与我使用Windows窗体和数据集的方式有所不同.疯狂的事情是,如果我在Datagrid的click事件中做这样的事情.....

var mySelection = dgSearch.SelectedItem;

我可以看到整个信息行.但是对于我的一生,我无法遍历这些数据.我认为这是一个iList,但我似乎无法将这些数据分解为元素.
I have a WPF datagrid bound to a Linq query. The first column is the id from the table. When a user clicks on the datagrid I need to be able to take that ID and search further on a different form in my program. I have literally combed for hours on Google and made some progress but this is way different from when I was using Windows Forms and Datasets. The crazy thing is if I do something like this in the click event for the Datagrid.....

var mySelection = dgSearch.SelectedItem;

I can see the entire row of information. But for the life of me I cannot iterate through this data. I think it is an iList but I cannot seem to break that data down into elements.


这篇关于绑定到Linq查询时获取数据网格选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆