I have a custom Order
class, groups of which are stored in List<Order>
and a DataGridView. I think the problem is in my implementation so here's how I'm using it:
In the form enclosing DataGridView
(as OrdersDataGrid
):
public partial class MainForm : Form
{
public static List<Order> Orders;
public MainForm()
{
// code to populate Orders with values, otherwise sets Orders to new List<Order>();
OrdersDataGrid.DataSource = Orders;
}
Then in another form that adds an Order:
// Save event
public void Save(object sender, EventArgs e) {
Order order = BuildOrder(); // method that constructs an order object from form data
MainForm.Orders.Add(order);
}
From what I can tell from the console this is added successfully. I thought the DataGrid would be updated automatically after this since Orders
has changed - is there something I'm missing?
The DataGrid accepts the class since it generates columns from the members.