Reputation: 2242
After querying from database, I fill the result into dataset, suppose there are 10 columns.
And then i have to show 5 of the 10 columns into datagridview.
My way is to create a new DataTable with the 5 columns, and copy the value from the original dataset. It works, but i don't think it's a good way.
Any suggestion?
-----------------------
I am using C# for Form Application.
I prefer programic way to implement.
Upvotes: 1
Views: 9970
Reputation: 684
You can hide selected column by setting Visible to false, like datagridview.Columns[0].Visible = false
Upvotes: 5
Reputation: 4083
Assuming that you set the dataset as the datasource of the gridview, you can specify which columns do you want to display in the gridview by clicking on the > button in the design view and selecting edit columns.
Please see the following article: http://msdn.microsoft.com/en-us/library/ms972948.aspx
Upvotes: 1