C#遍历CheckedListBox中的勾选项

news/2024/8/30 22:52:40 标签: c#

正确的代码:

string selectedItem = string.Empty;
            for(int i=0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemChecked(i))
                { selectedItem = selectedItem + " " + checkedListBox1.Items[i].ToString(); }
            }

以下代码只能选择最后单击的那项

string selectedItem = string.Empty;
            for(int i=0; i < checkedListBox1.SelectedItems.Count; i++)
            {
               
                 selectedItem = selectedItem + " " + checkedListBox1.SelectedItems[i].ToString(); 
            }

checked 针对勾选   selected针对单击选择的项  一定要注意哦!

转载于:https://www.cnblogs.com/zqyo2000z/p/7392337.html


http://www.niftyadmin.cn/n/1075529.html

相关文章

openstack控制台出错Failed to connect to server (code: 1006)

#错误描述 &#xff1a; 打开openstack控制台后&#xff0c;控制台出错&#xff0c;显示Failed to connect to server (code: 1006)&#xff0c;如下图&#xff1a; #错误分析&#xff1a; 点击只显示控制台可看到地址是controller&#xff1a;6080…… 应该是域名解析出错。…

重启Apache出现警告信息Could not reliably determine the server's fully qualified domain name,

1.错误描述&#xff1a; 重启Apache服务出现下列警告&#xff1a; service apache2 restart * Restarting web server apache2 AH00558: apache2: Could not reliably determine the servers fully qualified domain name, using 192.168.1.1. Set the ServerName directive g…

Disk /dev/mapper/vg-var doesn't contain a valid partition table

问题描述 rootcompute-44:~# fdisk -lDisk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units sectors of 1 * 512 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minim…

在Android中全屏显示GIF图片

1、自定义一个GifView 首先自定义一个GifView&#xff0c;用于显示Gif图片。GifView的代码参考自https://github.com/Cutta/GifView。 package cc.duduhuo.gifviewdemo.view;import android.annotation.SuppressLint; import android.content.Context; import android.graphics…

openstack多主机部署(ubuntu14.04)J版

拓扑图 部署前准备 安装ubuntu14.04 ssh设置 修改/etc/ssh/sshd_config 配置文档中的下面一句 # vi /etc/ssh/sshd_config PermitRootLogin yes # service ssh restart 网络设置 ip根据自己情况设置,这儿只列出一台的设置 # vi /etc/network/interfaces # This file …

oracle创建新用户

[转发] http://www.cnblogs.com/monkeybrother/p/6405314.html 1.首先我们可以用scott用户以sysdba的身份登录oracle.   conn scott/tiger as sysdba 2.然后我就可以来创建用户了. create user zs identified by zs; 3.修改用户的密码. alter user zs identified by 123456…

Openstack Nova Failed to allocate network(s)

错误描述&#xff1a; 上图的错误信息为 Error: 创建实例 "cirros" 失败: 请稍后再试 [错误: Build of instance 751267aa-e9e2-41c0-945b-9bbb94096849 aborted: Failed to allocate the network(s), not rescheduling.]. 计算节点中nova-compute.log的信息 2015…

HTML DOM 对象

完成一个操作可以用很多种的方法。下面的一些属性&#xff0c;方法&#xff0c;你同样在JQuery里面可以完成。 HTML DOM对象里面包含 Document 对象 Element 对象 Attribute 对象 Event 对象 Document对象 &#xff08;文档对象&#xff09; 主要用…