Winforms 如何在telerik radgridview的顶层显示多个独立模板
设置Indexnumber为模板索引的数据源节:Winforms 如何在telerik radgridview的顶层显示多个独立模板,winforms,templates,telerik,radgridview,Winforms,Templates,Telerik,Radgridview,设置Indexnumber为模板索引的数据源节: GridViewTemplate gvt = new GridViewTemplate(); gvt.AllowDeleteRow = false; gvt.AllowEditRow = false; gvt.ShowTotals = true;
GridViewTemplate gvt = new GridViewTemplate();
gvt.AllowDeleteRow = false;
gvt.AllowEditRow = false;
gvt.ShowTotals = true;
gvt.Caption = SubCaption[i];
radResult.MasterTemplate.Templates.Add(gvt);
radResult.Refresh();
我的看法是:
我必须怎么做?感谢advanceRadGridView通过MasterGridView模板仅提供一个主控级别。可以根据需要将任意多个子GridViewTemplates添加到主级。有关更多信息,请访问: 但是,这需要主模板和每个子GridViewTemplates之间的关系 为了从父级RadGridView中选项卡式视图的屏幕截图中实现您的设计,我可以建议以下方法:
radResult.MasterTemplate.Templates[IndexNumber].DataSource = dtl;
radResult.MasterTemplate.Templates[IndexNumber].Refresh();
radResult.Refresh();
radResult.MasterTemplate.Templates[IndexNumber].DataSource = dtl;
radResult.MasterTemplate.Templates[IndexNumber].Refresh();
radResult.Refresh();
private void RadForm1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'nwindDataSet.Products' table. You can move, or remove it, as needed.
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
// TODO: This line of code loads data into the 'nwindDataSet.Orders' table. You can move, or remove it, as needed.
this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
// TODO: This line of code loads data into the 'nwindDataSet.Categories' table. You can move, or remove it, as needed.
this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);
this.radGridView1.MasterTemplate.Columns.Add("MasterLevel");
this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.MasterTemplate.AllowAddNewRow = false;
this.radGridView1.ShowColumnHeaders = false;
this.radGridView1.ShowGroupPanel = false;
GridViewTemplate childTemplateCategories = new GridViewTemplate();
childTemplateCategories.Caption = "Categories";
foreach (DataColumn col in this.nwindDataSet.Categories.Columns)
{
childTemplateCategories.Columns.Add(col.ColumnName);
}
childTemplateCategories.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.Templates.Add(childTemplateCategories);
childTemplateCategories.HierarchyDataProvider = new GridViewEventDataProvider(childTemplateCategories);
GridViewTemplate childTemplateProducts = new GridViewTemplate();
childTemplateProducts.Caption = "Products";
foreach (DataColumn col in this.nwindDataSet.Products.Columns)
{
childTemplateProducts.Columns.Add(col.ColumnName);
}
childTemplateProducts.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.Templates.Add(childTemplateProducts);
childTemplateProducts.HierarchyDataProvider = new GridViewEventDataProvider(childTemplateProducts);
GridViewTemplate childTemplateOrders = new GridViewTemplate();
childTemplateOrders.Caption = "Orders";
foreach (DataColumn col in this.nwindDataSet.Orders.Columns)
{
childTemplateOrders.Columns.Add(col.ColumnName);
}
childTemplateOrders.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.Templates.Add(childTemplateOrders);
childTemplateOrders.HierarchyDataProvider = new GridViewEventDataProvider(childTemplateOrders);
this.radGridView1.RowSourceNeeded += new GridViewRowSourceNeededEventHandler(radGridView1_RowSourceNeeded);
this.radGridView1.Rows.Add("Master");
this.radGridView1.Rows[0].IsExpanded = true;
}
private void radGridView1_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
{
if (e.Template.Caption == "Categories")
{
foreach (DataRow row in this.nwindDataSet.Categories.Rows)
{
GridViewRowInfo r = e.Template.Rows.NewRow();
foreach (GridViewCellInfo cell in r.Cells)
{
cell.Value = row[cell.ColumnInfo.Name];
}
e.SourceCollection.Add(r);
}
}
else if (e.Template.Caption == "Products")
{
foreach (DataRow row in this.nwindDataSet.Products.Rows)
{
GridViewRowInfo r = e.Template.Rows.NewRow();
foreach (GridViewCellInfo cell in r.Cells)
{
cell.Value = row[cell.ColumnInfo.Name];
}
e.SourceCollection.Add(r);
}
}
else if (e.Template.Caption == "Orders")
{
foreach (DataRow row in this.nwindDataSet.Orders.Rows)
{
GridViewRowInfo r = e.Template.Rows.NewRow();
foreach (GridViewCellInfo cell in r.Cells)
{
cell.Value = row[cell.ColumnInfo.Name];
}
e.SourceCollection.Add(r);
}
}
}