0
votes

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.

2

2 Answers

4
votes

You can hide selected column by setting Visible to false, like datagridview.Columns[0].Visible = false

1
votes

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