• 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;
                        }
                    }
    
                }
    
            }
    
  • 相关阅读:
    38. Count and Say(C++)
    35. Search Insert Position(C++)
    29. Divide Two Integers(C++)
    c++读取utf-8格式中英文混合string
    一种局部二值化算法:Sauvola算法
    Ubuntu 1804 本地显示远程服务器文件
    caffe 预训练 或者Fine-Tuning 操作
    caffe/blob.hpp:9:34: fatal error: caffe/proto/caffe.pb.h: 没有那个文件或目录
    转载---LIBRARY_PATH和LD_LIBRARY_PATH环境变量的区别
    [leetcode-921-Minimum Add to Make Parentheses Valid]
  • 原文地址:https://www.cnblogs.com/hl3292/p/1881796.html
Copyright © 2020-2023  润新知