如何在GridControl中添加CheckBox并在表格中插入所选行的数据按钮在WPF中单击?

时间:2013-05-27 08:15:04

标签: c# wpf devexpress wpfdatagrid

我有一个GridControl,其中包含分组标题的数据。我想在第一列中添加CheckBox,并希望在按钮单击时将这些选定行插入表中。

protected void GetAllInfills()
        {
            List<Infill> infillList = new List<Infill>();
            infillList=BLL.GetAllInfills();
            if (infillList != null)
            {
                grdInfill.ItemsSource = infillList;
                grdInfill.GroupBy(grdInfill.Columns["Glass.GlassType"], ColumnSortOrder.Ascending);
                grdInfill.GroupBy(grdInfill.Columns["Glass.Glass_Description"], ColumnSortOrder.Ascending);
                grdInfill.AutoExpandAllGroups = true;

            }
        }

<DataTemplate x:Key="descriptionHeader">
                 <StackPanel Orientation="Vertical" Margin="4" Height="115" >
                <StackPanel Orientation="Horizontal" Margin="0" HorizontalAlignment="Left">
                    <Border BorderBrush="Black" HorizontalAlignment="Left"  BorderThickness="0.1" Width="500">
                            <!--<Image Source=".\Images\description_img.png"  Stretch="None" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1"/>-->
                            <StackPanel Orientation="Vertical" Margin="2">
                                <TextBlock Name="txtdesc1" Margin="2" Text="{Binding ElementName=txtdescription, Path=Text, Converter={StaticResource splitter}, ConverterParameter=0 }" Width="800" HorizontalAlignment="Left" ></TextBlock>
                                <TextBlock Name="txtdesc2" Margin="2" FlowDirection="LeftToRight" Text="{Binding ElementName=txtdescription, Path=Text, Converter={StaticResource splitter}, ConverterParameter=1 }"  TextWrapping="Wrap"  />
                                <TextBlock Name="txtdesc3" Margin="2" FlowDirection="LeftToRight" Text="{Binding ElementName=txtdescription, Path=Text, Converter={StaticResource splitter}, ConverterParameter=2 }" TextWrapping="Wrap"  />
                                <TextBlock Name="txtdesc4" Margin="2" FlowDirection="LeftToRight" Text="{Binding ElementName=txtdescription, Path=Text, Converter={StaticResource splitter}, ConverterParameter=3 }"   TextWrapping="Wrap"  />
                                <!--<TextBlock Name="txtdesc1" Margin="2" FlowDirection="LeftToRight" Text="{Binding Glass.GlassDescription1}"  TextWrapping="Wrap"  />
                            <TextBlock Name="txtdesc2" Margin="2" FlowDirection="LeftToRight" Text="{Binding Glass.GlassDescription2}" TextWrapping="Wrap"  />
                            <TextBlock Name="txtdesc3" Margin="2" FlowDirection="LeftToRight" Text="{Binding Glass.GlassDescription3}"   TextWrapping="Wrap"  />-->

                            </StackPanel>
                        </Border>
                    </StackPanel>

                        <Border BorderBrush="Black" HorizontalAlignment="Left"  BorderThickness="0.1" Width="1200">
                        <StackPanel Orientation="Horizontal" Width="1200" HorizontalAlignment="Left" Margin="2">
                             <TextBlock  Margin="2" FlowDirection="LeftToRight" Text="List By :"></TextBlock>
                            <Label Content="     " HorizontalAlignment="Left"  VerticalAlignment="Bottom"/>
                            <Button Name="BtnQuote" Content="Quote" Height="20" Margin="2" Width="80" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="BtnQuote_Click"  />
                            <Button Name="BtnElevation" Content="Elevation" Margin="2" Height="20" Width="80" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="BtnElevation_Click" />

                            <Button Name="BtnQuantity" Content="Quantity" Margin="2" Height="20" Width="80" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="BtnQuantity_Click"  />
                            <Button Name="BtnMark" Content="Mark" Height="20" Margin="2" Width="80" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="BtnMark_Click"  />
                            <Button Name="BtnWallLocation" Content="WallLocation" Margin="2" Height="20" Width="100" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="BtnWallLocation_Click"  />
                            <Button Name="BtnBuilding" Content="Building" Height="20" Margin="2" Width="80" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="BtnBuilding_Click"  />
                            <Button Name="BtnClear" Content="Clear" Height="20"  Margin="2" Width="80" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="BtnClear_Click"  />
                        </StackPanel>
                        </Border>
                        <TextBlock Name="txtdescription" Text="{Binding DisplayText}" Visibility="Hidden" Width="500" HorizontalAlignment="Left" ></TextBlock>
                </StackPanel>

            <!--</Border>-->
        </DataTemplate>
    </Window.Resources>

    <Grid>

    <dxg:GridControl Name="grdInfill"  Height="700" VerticalAlignment="Center" >
        <dxg:GridControl.Columns>
            <dxg:GridColumn FieldName="GlassType" AllowEditing="False"   />
                <dxg:GridColumn FieldName="Glass.Glass_Description" Header="Glass Description" AllowEditing="False" GroupValueTemplate="{StaticResource descriptionHeader}">
                </dxg:GridColumn>
                <dxg:GridColumn FieldName="Glass.GlassType" AllowEditing="False" />
               <dxg:GridColumn FieldName="Quantity" AllowEditing="False"/>
                <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 Name="grdInfillInner"  ShowTotalSummary="True" AutoWidth="True" DetailHeaderContent="True"  ShowIndicator="False" ShowGroupPanel="False">
            </dxg:TableView>
        </dxg:GridControl.View>
    </dxg:GridControl>

    </Grid>

请参阅屏幕显示了解更多详情..!帮助赞赏! enter image description here

0 个答案:

没有答案