示出的DataGridView相关数据 [英] Showing the related data in Datagridview

查看:135
本文介绍了示出的DataGridView相关数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据表:交易和帐户

I have two datatables: Transactions and Accounts.

事务和账户DataTable中的一个外键IDAccount。

Transaction has a foreign key IDAccount from Accounts dataTable.

我给你的DataGridView的DataSource属性的交易DataSource属性数据表。

I assign datasource property of Datasource property of Datagridview to Transactions dataTable.

我要Accounts.description IDAccount的欧洲工商管理学院在DataGridView中。

I want to Accounts.description insead of IDAccount in Datagridview.

我应该做些什么?

推荐答案

请一个绑定到IDAccount领域的 DataGridViewComboBoxColumn 并如下设置其属性:

Make the column in your DataGridView that's bound to the IDAccount field a DataGridViewComboBoxColumn and set its properties as follows:

  • 数据源:您的账户数据表
  • 的DisplayMember:说明
  • ValueMember:IDAccount

DataGridViewComboBoxColumn ValueMember 的DisplayMember 属性允许你存储和处理您的DGV(和数据源)您IDAccount价值的同时,显示给用户的描述值。 MSDN文章我联系解释得很好。

The DataGridViewComboBoxColumn's ValueMember and DisplayMember properties allows you to store and manipulate your IDAccount value in your DGV (and data source) while displaying to the user the Description value. The MSDN article I linked explains it well.

这篇关于示出的DataGridView相关数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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