DevExpress控件 GridControl中某一列列头添加一个复选框控件,复选框不是绑定数据源,是UnboundType类型 10
问题补充:以下每一行是用CheckEditSetting设置的复选框,想要做一个选中列头的复选框,然后以下复选框实现全选的功能,但是现在问题是选中列头,以下的复选框没有反...
问题补充:以下每一行是用CheckEditSetting设置的复选框,想要做一个选中列头的复选框,然后以下复选框实现全选的功能,但是现在问题是选中列头,以下的复选框没有反应,如何解决?
附部分代码:
XAML部分:
<dxg:GridControl.Columns>
<dxg:GridColumn Name="colSelect" FieldName="Selected" UnboundType="Boolean" AllowEditing="True" HorizontalHeaderContentAlignment="Center" ShowInColumnChooser="False" AllowColumnFiltering="False" AllowSorting="False" Width="35" >
<dxg:GridColumn.HeaderTemplate>
<DataTemplate>
<StackPanel>
<dxe:CheckEdit x:Name="ceSelectAll" ToolTipService.ToolTip="全选/取消全选" EditValueChanged="ceSelectAll_EditValueChanged" />
</StackPanel>
</DataTemplate>
</dxg:GridColumn.HeaderTemplate>
<dxg:GridColumn.EditSettings>
<dxe:CheckEditSettings IsThreeState="False" ClickMode="Press" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
C#代码部分:
private void ceSelectAll_EditValueChanged(object sender, EditValueChangedEventArgs e)
{
var ceSelectAll = (CheckEdit)sender;
if (ceSelectAll == null || ceSelectAll.EditValue == null) { return; }
for (int i = 0; i < gridControlLink.VisibleRowCount; i++)
{
int rowHandle = gridControlLink.GetRowHandleByVisibleIndex(i);
bool bIsSelect = Convert.ToBoolean(ceSelectAll.EditValue);
gridControlLink.SetCellValue(rowHandle , gridControlLink.Columns[0], bIsSelect);
}
} 展开
附部分代码:
XAML部分:
<dxg:GridControl.Columns>
<dxg:GridColumn Name="colSelect" FieldName="Selected" UnboundType="Boolean" AllowEditing="True" HorizontalHeaderContentAlignment="Center" ShowInColumnChooser="False" AllowColumnFiltering="False" AllowSorting="False" Width="35" >
<dxg:GridColumn.HeaderTemplate>
<DataTemplate>
<StackPanel>
<dxe:CheckEdit x:Name="ceSelectAll" ToolTipService.ToolTip="全选/取消全选" EditValueChanged="ceSelectAll_EditValueChanged" />
</StackPanel>
</DataTemplate>
</dxg:GridColumn.HeaderTemplate>
<dxg:GridColumn.EditSettings>
<dxe:CheckEditSettings IsThreeState="False" ClickMode="Press" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
C#代码部分:
private void ceSelectAll_EditValueChanged(object sender, EditValueChangedEventArgs e)
{
var ceSelectAll = (CheckEdit)sender;
if (ceSelectAll == null || ceSelectAll.EditValue == null) { return; }
for (int i = 0; i < gridControlLink.VisibleRowCount; i++)
{
int rowHandle = gridControlLink.GetRowHandleByVisibleIndex(i);
bool bIsSelect = Convert.ToBoolean(ceSelectAll.EditValue);
gridControlLink.SetCellValue(rowHandle , gridControlLink.Columns[0], bIsSelect);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询