Having done some web trawling I've ended up with this:
Expand|Select|Wrap|Line Numbers
- private void AddRow(string thing,string thingdesc)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.CreateCells(MyGrid); // #1
- row.Cells[0].Value = "Add"; // #2 this makes it work
- MyGrid.Rows.Add(row); // #3 need this before adding data
- row.Cells["Selected"].Value = "Add";
- row.Cells["Model"].Value = thing;
- row.Cells["Description"].Value = thingdesc;
- row.Cells["Scenario"].Value = "Basic";
- row.Cells["ModelLoop"].Value = "1";
- row.Cells["LaunchCount"].Value = "1";
- }
Also the data has to be added after #3. Putting it between #2 & #3 gives e.g. Column named Selected cannot be found.
I would have thought #1 was sufficient to allow me to add the data.
Any thoughts?
Simon