0

我有两个表:交易和账户。

Transaction 有一个来自 Accounts Table 的外键 IDAccount。

我将 Datagridview 的数据源属性的数据源属性分配给事务表。

我想在 Datagridview 中的 IDAccount 中进行 Accounts.description。

我必须做什么?

4

1 回答 1

1

There is a solution to this problem offered here which involves doing some custom code to inspect each property and determine if it belongs to the main bound object or to a child object.

This looks like a good solution except it doesn't support editing or sorting based on these properties.

Another approach (which I would probably recommend since it is simpler) is to introduce an AccountDescription property to your Transaction object.

public class Transaction
{
    private Account _account

    public string AccountDescription
    {
        get { return _account.description; }
        set { _account.description = value; }
    }
}

You might also need to implement some custom INotifyPropertyChanged code so databinding works nicely.

于 2011-04-12T11:39:55.610 回答