void MakeGrid() { string[] cols ={ "First", "Second", "Third" }; CreateTable(cols);//fills the data table with columns called First, Second and Third List<string[]> rows = new List<string[]>(); string[] firstRow ={"1","2","3"}; string[] secondRow ={"4","5","6"}; string[] thirdRow ={ "7", "8", "9" }; string[] fourthRow ={ "10", "11", "12" }; rows.Add(firstRow); rows.Add(secondRow); rows.Add(thirdRow); rows.Add(fourthRow); AddRows(rows);//fills the data table with the rows according to the predefined columns this.dataGridView1.DataSource = table;//merge the datatable with the datagridview }
calling MakeGrid() will create your datatable with some sample data and bind it to the dataGridView in the form.
If you're also interested in binding your DataGridView to a SQL Server database or to a collection of objects, then the Dot Net Perls website has some useful articles.
Like the answers above, I also used DataGridView, and I recomend it. It is a powerfull tool that not only display the data as a table, it's a dinamic table and can be used in some nice ways... good luck with it.
4 answers
to use the grid view, drag and drop it on the form, then make a datatable for it and set the datasource of the gridview to that datatable.
calling MakeGrid() will create your datatable with some sample data and bind it to the dataGridView in the form.
answered one year ago by:
1556
I found out that we can use Data grid view for making the table, any idea on how to use this? I am still very beginner in c sharp :(
answered one year ago by:
301
If you're also interested in binding your DataGridView to a SQL Server database or to a collection of objects, then the Dot Net Perls website has some useful articles.
Check out the links on this page.
answered one year ago by:
17279
Like the answers above, I also used DataGridView, and I recomend it.
It is a powerfull tool that not only display the data as a table, it's a dinamic table and can be used in some nice ways...
good luck with it.
answered one year ago by:
30