禁止在复选框一个ListView单个复选框 [英] Disable single checkbox in a ListView with checkboxes

查看:216
本文介绍了禁止在复选框一个ListView单个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复选框一个ListView:

I have a ListView with checkboxes:

        listView1.View = View.Details;
        listView1.CheckBoxes = true;

        ListViewItem item1 = new ListViewItem("ONE");
        ListViewItem item2 = new ListViewItem("TWO");
        ListViewItem item3 = new ListViewItem("THREE");

        listView1.Items.Add(item1);
        listView1.Items.Add(item2);
        listView1.Items.Add(item3);

我想只禁用第二个复选框,这可能吗?

I would like to disable only the second checkbox, is it possible?

在此先感谢。

推荐答案

我认为你可以做到这一点与业主图纸使用 DRAWITEM 事件。在事件处理程序,画充满了一个长方形的 SystemColors.Window 在复选框,将其隐藏。

I think you can do that with owner drawing using the DrawItem event. In the event handler, draw a rectangle filled with SystemColors.Window over the check box to hide it.

我也实施了复选框躲在第三方控制更好的ListView防爆preSS 。项目有一个名为布尔属性的 AllowShowCheckBox ,您可以分别设置为false每一个项目。它还支持三态复选框。

I have also implemented check box hiding in 3rd party control Better ListView Express. Items have a boolean property named AllowShowCheckBox which you can set to false on every item separately. It also supports three-state check boxes.

这篇关于禁止在复选框一个ListView单个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆