你如何禁用项ListView控件在.NET 3.5中 [英] How do you disable an item in listview control in .net 3.5

查看:226
本文介绍了你如何禁用项ListView控件在.NET 3.5中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET 3.5的Windows窗体我有复选框=真列表视图。是否有可能从检查中黯淡了或禁用某些项目,以prevent用户?

In .net 3.5 windows forms I have a listview with "CheckBoxes" = true. Is it possible to dim out or disable some items to prevent the user from checking the box?

推荐答案

您可以使用ListBoxItem.ForeColor和UseItemStyleForSubItems属性,使该项目看起来黯淡。使用SystemColors.GrayText挑选的主题色彩供残疾人使用的物品。避免禁用的选择,它prevents使用键盘的用户。只有取消该复选框检查。例如:

You can use the ListBoxItem.ForeColor and UseItemStyleForSubItems properties to make the item look dimmed. Use SystemColors.GrayText to pick the theme color for disabled items. Avoid disabling selection, it prevents the user from using the keyboard. Only disable the checkbox checking. For example:

    private void listView1_ItemCheck(object sender, ItemCheckEventArgs e) {
        // Disable checking odd-numbered items
        if (e.Index % 2 == 1) e.NewValue = e.CurrentValue;
    }

这篇关于你如何禁用项ListView控件在.NET 3.5中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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