title: populating datagridview with list of objects
body: <p>I have a List that contains a series of transaction objects.  What I'm trying to do is to display these transaction objects in a Datagridview control on loading a form, basically the Datagridview should represent something of a transaction register to display the data for each of the transaction objects in the list.</p>
  <p>I must admit to a lack of experience when it comes to using Datagridviews and I'm having some difficulty with understanding what I need to do here.</p>
  <p>My question is, how do I go about getting the details of each of the objects in the list to display in the Datagridview?</p>
  <p>Here is my code.</p>
  <p>First the transaction class:</p>
  <pre><code>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 of values.
      public decimal Amount
      {
          get
          {
              return amount;
          }
          set
          {
              amount = value;
          }
      }
      public string Type
      {
          get
          {
              return type;
          }
          set
          {
              type = value;
          }
      }
      public decimal Balance
      {
          get
          {
              return balance;
          }
          set
          {
              balance = value;
          }
      }
      public string Date
      {
          get
          {
              return date;
          }
          set
          {
              date = value;
          }
      }
      public string TransNum
      {
          get
          {
              return transNum;
          }
          set
          {
              transNum = value;
          }
      }
      public string Description
      {
          get
          {
              return description;
          }
          set
          {
              description = value;
          }
      }
  
      public decimal addCredit(decimal balance, decimal credit)
      {
          decimal newBalance;
          newBalance = balance + credit;
          return newBalance;
      }
  
      public decimal subtractDebit(decimal balance, decimal debit)
      {
          decimal newBalance;
          newBalance = balance - debit;
          return newBalance;
      }
      }
  }
  </code></pre>
  <p>Now the code for the &quot;Register&quot; form:</p>
  <pre><code>    public partial class Register : Form
  {
      List&lt;Transaction&gt; tranList = new List&lt;Transaction&gt;();
  
      public Register(List&lt;Transaction&gt; List)
      {
          InitializeComponent();
          this.tranList = List;
      }
  
      private void Register_Load(object sender, System.EventArgs e)
      {
          //regView represents the Datagridview that I'm trying to work with
          regView.AutoSize = true;
          regView.DataSource = tranList;
          regView.Rows.Add(tranList[0]);
      }
  }
  </code></pre>
  <p>And here's the output I get.
  <img src="https://i.stack.imgur.com/Ny4Lq.jpg" alt="Register output" /></p>