我有一个包含一系列事务对象的List.我想要做的是在加载表单时在Datagridview控件中显示这些事务对象,基本上Datagridview应该表示事务寄存器的某些内容,以显示列表中每个事务对象的数据.
我必须承认在使用Datagridviews方面缺乏经验,而我在理解我需要做什么方面遇到了一些困难.
我的问题是,如何获取列表中每个对象的详细信息以显示在Datagridview中?
这是我的代码.
首先是交易类:
public class Transaction
{
// Class properties
private decimal amount;
private string type;
private decimal balance;
private string date;
private string transNum;
private string description;
// Constructor to create transaction object with values set.
public Transaction(decimal amount, string type, decimal currBal, string date, string num, string descrip)
{
this.amount = amount;
this.type = type;
this.balance = currBal;
this.date = date;
this.transNum = num;
this.description = descrip;
}
// Get and Set accessors to allow manipulation …Run Code Online (Sandbox Code Playgroud)