编辑通过LINQ设置数据源的datagrid [英] Edit datagrid that datasource is set via LINQ

查看:74
本文介绍了编辑通过LINQ设置数据源的datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何在通过LINQ设置数据源的datagrid中编辑e单元格值

Hi,
How to edit e cell value in datagrid that datasource is set via LINQ

var query = from a in context.Personelis
                          select a;
              dgvGrid.DataSource = query;
dgvGrid["AcountNo",3].value = 4;


它不会更改值

THANX


it does not change the value

THANX

推荐答案

绑定到匿名类型时数据网格视图处于ReadOnly模式的原因是匿名类型为ReadOnly.如果将视图绑定到仅具有只读属性的对象列表,则会得到相同的行为.


我知道的唯一解决方案是为可编辑的数据创建一个容器.具有定义get和set属性的类将为您提供作为结果的外观.
The reason that the data grid view is in ReadOnly mode when binding to anonymous types is that anonymous types are ReadOnly. You will get the same behaviour if you bind the view to a list of objects with only read only properties.


The only solution that I know of is to create a container for the data that is editable. A class with properties defining a get and set will give you what you are looking as the result.


这篇关于编辑通过LINQ设置数据源的datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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