示出的DataGridView相关数据数据、DataGridView

2023-09-04 23:33:30 作者:依风雨晴

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

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.

 
精彩推荐
图片推荐