zoukankan      html  css  js  c++  java
  • silverlight中CheckBox在DataGrid的全选/取消 hl3292修改

    http://www.cnblogs.com/kaixun001/archive/2009/02/16/1391722.html

    DataGrid控件没有rows等属性我们如何全选与取消呢,在运用过程中做了个人小结,如果还有好方法,多多学习:

     hl3292修改

     //选择页面所有记录

     <sdk:DataGrid x:Name="BankPenaltyLogDataGrid" AutoGenerateColumns="False" Width="960" ColumnWidth="Auto" IsReadOnly="True" MouseLeftButtonUp="BankPenaltyLogDataGrid_MouseLeftButtonUp_1" SelectionChanged="BankPenaltyLogDataGrid_SelectionChanged_1">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="状态"  Width="50">                   
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox x:Name="checkboxisCheck"></CheckBox>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <!--<sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="序号"       Width="*"  MinWidth="50" Binding ="{Binding ID}"   />-->                   
                        <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="日志类型"   Width="*"  MinWidth="50" MaxWidth="100" Binding ="{Binding log_type}"   />
                        <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="调用时间"   Width="*"  MinWidth="50" MaxWidth="200" Binding ="{Binding use_time}"  />
                        <!--:格式转换-->
                    <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="决定书编号" Width="*"  MinWidth="50"  MaxWidth="150" Binding ="{Binding decision_no}"  />
                        <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="输入信息"   Width="*"  MinWidth="50" MaxWidth="500" Binding ="{Binding input_info}"  />
                        <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="返回信息"   Width="*"  MinWidth="50" MaxWidth="500" Binding ="{Binding return_info}"  />
                        <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="详细"   Width="*"  MinWidth="40" MaxWidth="60"   >
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <HyperlinkButton Content="详细" Click="HyperlinkButton_Click"/>
                                    </StackPanel>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                    </sdk:DataGrid.Columns>
    
                </sdk:DataGrid>
    


           

    //选择页面所有记录
            private void btnSeletcAll_Click(object sender, RoutedEventArgs e)
            {
    
                foreach (object ovj in BankPenaltyLogDataGrid.ItemsSource)
                  
                {
                    if (null != BankPenaltyLogDataGrid.Columns[0] && null != BankPenaltyLogDataGrid.Columns[0].GetCellContent(ovj)) 
                    {
                        CheckBox cb = BankPenaltyLogDataGrid.Columns[0].GetCellContent(ovj).FindName("checkboxisCheck") as CheckBox;
                        if (null != cb)
                        {
                            cb.IsChecked = true;
                        }
                    }              
                }
    
            }
    
            //反选
            private void btnSelectOther_Click(object sender, RoutedEventArgs e)
            {
                foreach (object ovj in BankPenaltyLogDataGrid.ItemsSource)
                {
                    if (null != BankPenaltyLogDataGrid.Columns[0] && null != BankPenaltyLogDataGrid.Columns[0].GetCellContent(ovj))
                    {
                        CheckBox cb = BankPenaltyLogDataGrid.Columns[0].GetCellContent(ovj).FindName("checkboxisCheck") as CheckBox;
                        if (null != cb)
                        {
                            cb.IsChecked = !cb.IsChecked;
                        }
                    }
    
                }
    
            }
    
  • 相关阅读:
    Docker——WIN7 安装 Docker实战与入门
    TensorFlow——dropout和正则化的相关方法
    TensorFlow——学习率衰减的使用方法
    TensorFlow——MNIST手写数据集
    TensorFlow——分布式的TensorFlow运行环境
    类加载器
    死亡的对象
    spring boot整合kafka
    Java验证手机号
    类生命周期
  • 原文地址:https://www.cnblogs.com/hl3292/p/1881796.html
Copyright © 2011-2022 走看看