Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
How to disable particular items in checklistbox in c# not in asp.net.
Thanks in advance
Posted
Updated 21-Mar-12 0:02am
v2
Comments
Sergey Alexandrovich Kryukov 21-Mar-12 20:12pm    
What is that, "not in ASP.NET". Please, exact type of "CheckListBox"? Is it WPF, Forms, Silverlight?
--SA
Rishikesh_Singh 21-Mar-12 22:02pm    
Looks like the OP meant Winform by saying its not ASP.net.

You have to iterate through all the items with the index numbers and set the property is enabled to false

try this thread there is some code

http://forums.devarticles.com/net-development-43/disabling-an-item-in-a-checkedlistbox-c-11959.html[^]

another one

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/097d6baa-f924-45eb-8d64-f5baacf110f0[^]
 
Share this answer
 
Comments
S@53K^S 23-Mar-12 11:03am    
Reason for downvote ??
To disable any particular item use following
checkedListBox1.SetItemCheckState(0, CheckState.Indeterminate);
SetItemCheckState takes index of item and CheckState Enum
Indeterminate is used to show shaded appearance
 
Share this answer
 
v2
Comments
Rishikesh_Singh 21-Mar-12 21:59pm    
Reason for downvoting. isn't it correct way to disable particular item in winform application?
Would be happy if anyone downvoting provide some info or better alternative while downvoting.
sanit rana 22-Mar-12 2:07am    
thanks Rishikesh_Singh.But i really need disable those items which r checked
Rishikesh_Singh 22-Mar-12 8:01am    
yeah sorry about that.. but we really don't have any option in Checkedlistbox to disable. The best option seems to be creating either custom Checkedlistbox control deriving from CheckedListBox
or by using ListBox control and adding Checkbox controls to it like eg given at
social.msdn.microsoft.com/forums/en-US/winforms/thread/49927751-edc3-4c5c-97fe-8d192c2cfaa3/ by Zhi-Xin Ye.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900