KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a datagridview which we will call dataGridViewExample. My object (the uncommon datatypes is because my database is SQLite): class MyObject { public Int64 Vnr { get; set; } public string Name { get; set; } public Single Price { get; set; } public int Amount { get; set; } } Here is the relevant code: //This form gets called with a .ShowDialog(); in my form1. private List<MyObjecte> ExampleList = new List<MyObject>(); public MyForm() { dataGridViewExample.DataSource = OrdreInkøbsListe; } private void AddtoDataGridViewExample() { //Add a new MyObject to the list ExampleList.Add(new myObject() { Vnr = newVnr, Amount = newAmount, Price = newPrice, Name = newName }); //refresh datasource dataGridViewExample.DataSource = null; dataGridViewExample.Refresh(); dataGridViewExample.DataSource = OrdreInkøbsListe; ddataGridViewExample.Refresh(); } When MyForm gets called with a .ShowDialog, it shows up fine and displays my DataGridView example just fine. As you can read from the code, the ExampleList is initially empty, so it just shows an empty datagridview with 4 columns: Vnr, Name, Price & Amount. If I click inside it etc. nothing happens - so everything is working as planned, so far. Everytime I call AddtoDataGridViewExample() it adds the new object to the Datagridview, and the datagridview does update, listing all the objects added so far (they show themself as rows, again according to plan). Now, remember that I just said that nothing happened if you clicked inside DataGridViewExample before I have called AddtoDataGridViewExample() ? Well, after having called AddtoDataGridViewExample() once or more, the program will crash if I cl
Tags (comma-separated)
Save Edits
Cancel