PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Disable Checkbox ListViewItem
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Disable Checkbox ListViewItem
![]() |
Disable Checkbox ListViewItem |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
How can I disable a listviewitem which is basically a checkbox. Suppose I
have 10 checkboxes in my ListView and I want three of them disabled so that the user can not check/uncheck those three items. I am using C#. Thanks in advance for your help. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
A checkbox is in reality simply 2 different state images (one for the
checcked box and one for the unchecked box) that are taken from a system supplied image list and applied to the listview item as appropriate. Unfortunately .NET doesn't provide an event for when the state image index changes so you'll have to override WndProc and handle the LVN_ITEMCHANGING notification. Here's code that does most of this (in VB.NET): http://groups.google.se/group/micro...e99eb3ffc?hl=sv However, this code checks for changes to the selected state flag (LVIS_SELECTED). Change this to check for the new state image index instead (different bits in the state parameter) and return 1 to prevent the change (0 to allow it). The state image index is 1 for the unchecked box and 2 for the checked one. If you set it to 0 the checkbox will be removed Read more using the following keywords: LVITEM, INDEXTOSTATEIMAGEMASK, LVN_ITEMCHANGING, NMLISTVIEW The following code should give you the state image index provided the code in the link above (still in VB.NET): ((nmlv.uNewState And &HF000) >> 12) /claes "SAHUS" <SAHUS@discussions.microsoft.com> wrote in message news:601FCB4E-B0C9-447E-BEE9-E1ED5F877E42@microsoft.com... > How can I disable a listviewitem which is basically a checkbox. Suppose I > have 10 checkboxes in my ListView and I want three of them disabled so that > the user can not check/uncheck those three items. > > I am using C#. > > Thanks in advance for your help. |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

