zoukankan      html  css  js  c++  java
  • C# WinForm CheckedListBox 使用的相关简单总结

    1. 如何:确定 Windows 窗体 CheckedListBox 控件中的选定项

    当显示 Windows 窗体 CheckedListBox 控件中的数据时,
    可以循环访问 CheckedItems 属性中存储的集合,或者使用 GetItemChecked 方法逐句通过列表来确定选中的项。
    GetItemChecked 方法接受一个项索引号作为参数,并返回 true 或 false。

    可能与您期望的相反,SelectedItems 和 SelectedIndices 属性并不确定哪些项已选中;
    它们确定哪些项为突出显示。


    // Determine if there are any items checked.
    if(checkedListBox1.CheckedItems.Count != 0)
    {
       // If so, loop through all checked items and print results.
       string s = "";
       for(int x = 0; x <= checkedListBox1.CheckedItems.Count - 1 ; x++)
       {
          s = s + "Checked Item " + (x+1).ToString() + " = " + checkedListBox1.CheckedItems[x].ToString() + "\n";
       }
       MessageBox.Show (s);
    }

    即CheckedItems    表示 CheckBox选中 的项
      SelectedItems   表示 当前反蓝显示的项  SelectedIndex

    2.常用属性:
      CheckOnClick
      ThreeDCheckBoxes

    3.常用事件:
     ItemCheck
     SelectedIndexChanged

    4.不用再试图 生成的CheckedListBox有部分选项不可用 部分选项可用
      如果想实现上面的效果 可以利用Panel等容器结合CheckBox等控件来实现
      因为this.checkedListBox1.Items[i]是Object 不支持Enabled

  • 相关阅读:
    Python爬虫-05:Ajax加载的动态页面内容
    Python爬虫-04:贴吧爬虫以及GET和POST的区别
    Python-爬虫03:urllib.request模块的使用
    Python Numpy-基础教程
    8皇后算法
    迷宫算法
    归并排序
    查找算法
    排序算法
    设计模式
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1387374.html
Copyright © 2011-2022 走看看