This is a migrated thread and some comments may be shown as answers.

new radgridview from code behind

1 Answer 622 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 28 Aug 2014, 05:33 AM
is it possible to add a radgridview control to a tabcontrol/tabitem programmatically? i need to dynamically create tabs and then populate them with a grid that has a radgridview, radchart, etc.

i can't figure out how to do this, so i'm starting to think it isn't possible. if that's the case, is there a way to somehow template the tabs in xaml so i can simply instantiate them in code behind and the structure is already built?

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 28 Aug 2014, 02:16 PM
Hi,

Everything you can do in XAML, you can also implement in code.
You can create RadGridView in code similar to:
RadGridView grid = new RadGridView();
grid.ItemsSource = model.Clubs;
// Columns will be auto generated foreach property of the bound business objects (of type Club)
// You can also add other columns through grid.Columns collection
GridViewDataColumn column = new GridViewDataColumn();
grid.Columns.Add(column);
 
// Configure other settings
grid.Name = "clubsGrid1";

// Add RadGridView to the Grid defined in Xaml
this.LayoutRoot.Children.Add(grid);

// Set the proper RowDefinition if needed
Grid.SetRow(grid, 2);

LayoutRoot is an instance of WPF Grid.
<Grid x:Name="LayoutRoot">...</Grid>

You can also check the How to create a Grid in WPF Dynamically blog post.

As to your question on TabItems, I would suggest you to post them in the respective forums.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Anthony
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or