Linq DataGridview设置从文本框到组合框的列 [英] Linq DataGridview Set column from textbox to combobox

查看:109
本文介绍了Linq DataGridview设置从文本框到组合框的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此实现的简单部分很快完成了.我创建了一个linq查询,并将其设置为我的datagridview的数据源.我现在想做的是将由linq查询创建的列之一设置为datagridviewcomboboxcolumn.我也希望此列数据源是字符串数组,而不是另一个数据库表.

我目前所做的是将另外一列添加为datagridviewcomboboxcolumn,并将数据库属性手动更改为所选项目.但是这个解决方案带来了一个大问题:重新加载表单时,我无法将所选项目还原为每个组合框的``formattedvalue''属性.我没有发布该代码,因为到目前为止,它工作得很好.

The easy part of this implementation was done pretty quickly. I created a linq query and set it as the datasource of my datagridview. what i am now trying to do is set one of the columns, created by the linq query, to a datagridviewcomboboxcolumn. also i want this columns datasource to be an array of strings, not another database table.

what i have done currently is adding an additional column as datagridviewcomboboxcolumn and manually changed the database property to the selected item. but with this solution comes one big problem: when the form reloads i am unable to restore the selected items to be the ''formattedvalue'' property of each combobox.I am not posting that code, because except to that point it works well.

推荐答案

替代解决方案是在后端编写存储过程,该过程将获取数据库元素/列以及用户填充的数据.通过这种方法,您可以从数据库分配直接来源.
Alternative solution is to write a stored procedure in the back end, which fetches the data base elements/columns and the user populated data. With this approach, you can assign the direct source from DB.


这篇关于Linq DataGridview设置从文本框到组合框的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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