zoukankan      html  css  js  c++  java
  • CheckBox状态多选

    前:

     1   <StackPanel Margin="10">
     2             <Label FontWeight="Bold">Application Options</Label>
     3             <StackPanel Margin="10,5">
     4                 <CheckBox IsThreeState="True" Name="cbAllFeatures" Checked="cbAllFeatures_CheckedChanged" Unchecked="cbAllFeatures_CheckedChanged">Enable all</CheckBox>
     5                 <StackPanel Margin="20,5">
     6                     <CheckBox Name="cbFeatureAbc" Checked="cbFeature_CheckedChanged" Unchecked="cbFeature_CheckedChanged">Enable feature ABC</CheckBox>
     7                     <CheckBox Name="cbFeatureXyz" IsChecked="True" Checked="cbFeature_CheckedChanged" Unchecked="cbFeature_CheckedChanged">Enable feature XYZ</CheckBox>
     8                     <CheckBox Name="cbFeatureWww" Checked="cbFeature_CheckedChanged" Unchecked="cbFeature_CheckedChanged">Enable feature WWW</CheckBox>
     9                 </StackPanel>
    10             </StackPanel>
    11         </StackPanel>
     1         private void cbAllFeatures_CheckedChanged(object sender, RoutedEventArgs e)
     2         {
     3             bool newVal = (cbAllFeatures.IsChecked == true);
     4             cbFeatureAbc.IsChecked = newVal;
     5             cbFeatureXyz.IsChecked = newVal;
     6             cbFeatureWww.IsChecked = newVal;
     7         }
     8 
     9         private void cbFeature_CheckedChanged(object sender, RoutedEventArgs e)
    10         {
    11             cbAllFeatures.IsChecked = null;
    12             if ((cbFeatureAbc.IsChecked == true) && (cbFeatureXyz.IsChecked == true) && (cbFeatureWww.IsChecked == true))
    13                 cbAllFeatures.IsChecked = true;
    14             if ((cbFeatureAbc.IsChecked == false) && (cbFeatureXyz.IsChecked == false) && (cbFeatureWww.IsChecked == false))
    15                 cbAllFeatures.IsChecked = false;
    16         }
  • 相关阅读:
    Anaconda设置虚拟环境并打包exe
    [转]Anaconda, conda, pyenv, virtualenv的区别
    [闲记]2020-2-13
    集合笔记
    Python_列表(list)
    LeetCode 1711. 大餐计数 做题小结
    LeetCode 242. 有效的字母异位词 做题小结
    GitHub Actions教程 使用selenium自动化
    LeetCode 5641. 卡车上的最大单元数 做题小结
    git 批量删除文件夹和文件
  • 原文地址:https://www.cnblogs.com/ants_double/p/5366428.html
Copyright © 2011-2022 走看看