Filling a DataGrid without a DataSource
-
Can someone please help me filling a DataGrid without a DataSource. I'm used to work with a component called the True DBGrid made by ComponentOne for VB6, and it was a walk in the park to change the cells' value. Surely there's a way to modify the values without a source, right? Thanks in advance!
-
Can someone please help me filling a DataGrid without a DataSource. I'm used to work with a component called the True DBGrid made by ComponentOne for VB6, and it was a walk in the park to change the cells' value. Surely there's a way to modify the values without a source, right? Thanks in advance!
I Don't know if I understand your question correcly, but if you are using VS2005, and a DataGridView control, you can do this: 'Drop the control on your form 'Add two columns Me.DataGridView1.Columns.Add("Col1", "FirstColName") Me.DataGridView1.Columns.Add("Col2", "SecondColName") 'Add some rows - 5 in this case Me.DataGridView1.Rows.Add(5) 'Modify the Data in the control Me.DataGridView1.Item(0, 0).Value = "Hello" 'Row 0, Column 0 Me.DataGridView1.Item(0, 1).Value = "Dude" 'Row 1, Column 0
-
Can someone please help me filling a DataGrid without a DataSource. I'm used to work with a component called the True DBGrid made by ComponentOne for VB6, and it was a walk in the park to change the cells' value. Surely there's a way to modify the values without a source, right? Thanks in advance!
You could do how Richard described, but if you're going to save the data in the grdi, you'd be better off binding the grid to a DataTable you create. The DataTable object can save, and load, the data into/from an XML file without a pile of code on your part.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007