Home › Forums › WinForms controls › Xceed Grid for WinForms › Selecting which columns to add to Datagrid from dataset
-
AuthorPosts
-
#12898 |
How do I pick which columns from the data set to display in my grid instead of showing them all?
This is the code I am using to set it up and still it shows everything on that DataSet:
myGrid=new Xceed::Grid::GridControl();
colFecha = new DataBoundColumn( “fecha” );
colFecha->Width=120;
myGrid->Columns->Add( colFecha );
colRotation = new DataBoundColumn( “rotation” );
colRotation->Width=70;
myGrid->Columns->Add( colRotation );
colTv = new DataBoundColumn( “tv” );
colTv->Width=50;
myGrid->Columns->Add( colTv );
colTeamName = new DataBoundColumn( “teamname” );
colTeamName->Width=230;
myGrid->Columns->Add( colTeamName );
colGsMoney = new DataBoundColumn( “gsmoney” );
colGsMoney->Width=100;
myGrid->Columns->Add( colGsMoney );
colSpreadChart = new DataBoundColumn( “spreadchart” );
colSpreadChart->Width=60;
myGrid->Columns->Add( colSpreadChart );
colMoneyLine = new DataBoundColumn( “moneyline” );
colMoneyLine->Width=70;
myGrid->Columns->Add( colMoneyLine );
colMoneyChart = new DataBoundColumn( “moneychart” );
colMoneyChart->Width=60;
myGrid->Columns->Add( colMoneyChart );
myGrid->Location=Point(5,40);
myGrid->AllowCellNavigation=true;
myGrid->Size=Drawing::Size(1000,500);
myGrid->LicenseKey=S”SAMPLE-APPLICATION-KEY”;
Controls->Add(myGrid);
Imported from legacy forums. Posted by john13 (had 2843 views)
I assume you are doing something like:
myGrid.SetDataBinding( dataSet1, “Money” );
This will bind the entire dataset to the grid. You can then do:
foreach( Xceed.Grid.Column GrdCol In myGrid)
{
GrdCol.Visible = False;
}Then:
myGrid.Columns[ “fecha”].Visible = True;
myGrid.Columns[ “fecha”].Width=120;
myGrid.Columns[ “rotation”].Visible = True;
myGrid.Columns[ “rotation”].Width=70;You can also set the VisibleIndex to control the positions of the columns.
Imported from legacy forums. Posted by Kareem (had 240 views)
There has to be an easier way of doing this, even the Microsoft datagrid has the “Autogeneratecolumns” property.
Imported from legacy forums. Posted by aquaboltar (had 3567 views)
-
AuthorPosts
- You must be logged in to reply to this topic.