In my application, I have a DataGridView, which its data source depends on the button that you click. EG. By clicking "Total Downloads", it will look like this:
dataGridView1.DataSource = totalDownloads();
Or loading onto a player
dataGridView1.DataSource = playerDownloads();
Each method receives data through an SQL query and returns a dataTable of this information.
However, with my following code:
dataGridView1.DataSource=getStats(); public DataTable getStats() { DataTable table1 = new DataTable("Totals"); table1.Columns.Add("Park Name"); table1.Columns.Add("Author"); table1.Columns.Add("Total Downloads"); table1.Columns[2].DataType = typeof(int); table1.Columns.Add("Rating (Max 5)"); table1.Columns[3].DataType = typeof(float); table1.Rows.Add(name,author,download, rating); } return table1; }
I expected to see the colas in order: "Park Name" "Author" "Total Downloads" "Rating", However, they are included in the "Downloads", "Park Name", "Author", "Rating"
I read that add: dataGridView1.AutoGenerateColumns = false; this will fix ... however, it has nothing to do with order at all ...
thanks for the help!
c #
user1662290
source share