C# 如何在运行时从代码隐藏中删除WPF中DevExpress GridControl的分组?
我有一个GridControl,它由使用实体的列表绑定。我在运行时将分组应用于网格。我想在运行时从代码隐藏中删除/更改分组列在wpf中是否可能C# 如何在运行时从代码隐藏中删除WPF中DevExpress GridControl的分组?,c#,wpf,devexpress,gridcontrol,C#,Wpf,Devexpress,Gridcontrol,我有一个GridControl,它由使用实体的列表绑定。我在运行时将分组应用于网格。我想在运行时从代码隐藏中删除/更改分组列在wpf中是否可能 <dxg:GridControl Name="grdInfill" Height="700" VerticalAlignment="Top" > <dxg:GridControl.Columns> <dxg:GridColumn FieldName="GlassType" Allow
<dxg:GridControl Name="grdInfill" Height="700" VerticalAlignment="Top" >
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="GlassType" AllowEditing="False" />
<dxg:GridColumn FieldName="GlassDescription" GroupValueTemplate="{StaticResource descriptionHeader}">
<!--GroupValueTemplate="{StaticResource descriptionHeader}"-->
<!--Header="GlassDescription" DisplayMemberBinding="{Binding Path=RowData.Row.GlassDescription, Mode=TwoWay}"-->
</dxg:GridColumn>
<dxg:GridColumn FieldName="GlassType" AllowEditing="False" />
<dxg:GridColumn Name="qty" Header="Quantity" AllowEditing="False" DisplayMemberBinding="{Binding Path=RowData.Row.Quantity, Mode=TwoWay}" /> <!--FieldName="Quantity"-->
<dxg:GridColumn FieldName="Width" AllowEditing="False" Header="Length"/>
<dxg:GridColumn FieldName="Height" AllowEditing="False"/>
<dxg:GridColumn FieldName="Elevation" AllowEditing="False"/>
<dxg:GridColumn FieldName="Mark" AllowEditing="False"/>
<dxg:GridColumn FieldName="GlassTag" AllowEditing="False"/>
<dxg:GridColumn FieldName="WallLocation" AllowEditing="False"/>
<dxg:GridColumn FieldName="SquareFoot" AllowEditing="False"/>
<dxg:GridColumn FieldName="Weight" AllowEditing="False"/>
<dxg:GridColumn FieldName="UnitCost" AllowEditing="False"/>
<dxg:GridColumn FieldName="TotalCost" AllowEditing="False"/>
<dxg:GridColumn FieldName="FuelSurcharge" AllowEditing="False"/>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView ShowTotalSummary="True" AutoWidth="True" DetailHeaderContent="True" ShowIndicator="False" ShowGroupPanel="False"><!--GroupRowTemplate="{StaticResource descriptionHeader}"-->
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
protected void GetAllInfills()
{
List<Infill> infillList = new List<Infill>();
infillList=BLL.GetAllInfills();
if (infillList != null)
{
grdInfill.ItemsSource = infillList;
grdInfill.GroupBy(grdInfill.Columns["GlassType"], ColumnSortOrder.Ascending);
grdInfill.GroupBy(grdInfill.Columns["GlassDescription"], ColumnSortOrder.Ascending);
grdInfill.AutoExpandAllGroups = true;
}
}
受保护的void GetAllInfills()
{
List inflillist=新列表();
inflillist=BLL.GetAllInfills();
如果(内嵌!=null)
{
grdInfill.ItemsSource=填充;
grdInfill.GroupBy(grdInfill.Columns[“GlassType”],ColumnSortOrder.升序);
grdInfill.GroupBy(grdInfill.Columns[“GlassDescription”]、ColumnSortOrder.升序);
grdInfill.AutoExpandAllGroups=true;
}
}
现在单击按钮“我想从代码隐藏中删除或更改WPF中的分组?”要按单个列的值取消数据分组,请执行以下操作之一:
- 将列的属性设置为-1
- 调用该方法
若要取消网格分组,请使用该方法。谢谢@DmitryG它成功了!请你帮我解决@SHEKHARSHETE的问题。乍一看,这是一个非常简单的任务-你可以使用custom在模板级别将DisplayText拆分为三个部分。不幸的是,我今天没有时间在代码中演示这种方法…好的,当你有空的时候,请回复,直到那时我会尝试。。!好啊thanks@SHEKHARSHETE很高兴看到您使用“值转换器”方法解决了拆分文本的问题!