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

  • 相关阅读:
    使用NDK编译 libyuv <转>
    x264中重要结构体参数解释,参数设置,函数说明 <转>
    x264的一些参数设置对编码效率的影响
    首都儿研所开钙片!!!
    Android 媒体编解码器(转)
    opengl版本和扩展
    ffmpeg一揽子
    Android 使用SWIG生成Jni代码<转>
    CF 19D 线段树+set压缩坐标轴+离散化map
    android4.0 FaceDetection笔记
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1387374.html
Copyright © 2011-2022 走看看