DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

使用DXGrid控件时,如何通过辅助复选框列实现多行选择?

来源:本站原创   发布时间:2012-09-07   浏览:3255次

本示例只要展示了如何创建一个Boolean未绑定列,并使用它来选择/取消行。

VB.NET
<UserControl x:Class="DXGrid_MultiSelectColumn.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:local="clr-namespace:DXGrid_MultiSelectColumn"> <StackPanel>
<Button Click="BtnInvert_Click">Invert selection</Button>
<Button Click="BtnGetSelected_Click">Get selection</Button>
<dxg:GridControl x:Name="grid" CustomUnboundColumnData="grid_CustomUnboundColumnData" Height="500">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Id" />
<dxg:GridColumn FieldName="Number" />
<dxg:GridColumn FieldName="Selected" UnboundType="Boolean" AllowSorting="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:CheckEdit x:Name="PART_Editor" />
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView x:Name="view" AutoWidth="True" />
</dxg:GridControl.View>
</dxg:GridControl>
</StackPanel>
</UserControl>

C#
<UserControl x:Class="DXGrid_MultiSelectColumn.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:local="clr-namespace:DXGrid_MultiSelectColumn"><StackPanel>
<Button Click="BtnInvert_Click">Invert selection</Button>
<Button Click="BtnGetSelected_Click">Get selection</Button>
<dxg:GridControl x:Name="grid" CustomUnboundColumnData="grid_CustomUnboundColumnData" Height="500">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Id" />
<dxg:GridColumn FieldName="Number" />
<dxg:GridColumn FieldName="Selected" UnboundType="Boolean" AllowSorting="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:CheckEdit x:Name="PART_Editor"/>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView x:Name="view" AutoWidth="True" />
</dxg:GridControl.View>
</dxg:GridControl>
</StackPanel>
</UserControl>
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/326.html
在线
客服
微信
QQ 电话
023-68661681
返回
顶部