.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 15th, 2005, 08:50 PM
talljames talljames is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 15 talljames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 19 sec
Reputation Power: 0
Question Disabling an item in a checkedListBox C#

Hi all,

Does anyone know how to grey out and disable an item in a checkedListBox so that
the user cannot check that item.

with regards
James

Reply With Quote
  #2  
Old September 16th, 2006, 05:32 AM
Dabar2 Dabar2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 1 Dabar2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 39 sec
Reputation Power: 0
I dont now just that :)

A, I do not now but do you now how to add value from rows,
to CheckedListBox like it's items ?

Thansk

Reply With Quote
  #3  
Old October 30th, 2006, 07:44 AM
Lillyput Lillyput is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 2 Lillyput User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 6 sec
Reputation Power: 0
You can use the Enabled property

Example

CheckBoxList1.Items[1].Enabled = false;

you can use the above code to disbale the items of a check box list

Reply With Quote
  #4  
Old May 17th, 2007, 12:05 PM
jmlmartin jmlmartin is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 1 jmlmartin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 17 sec
Reputation Power: 0
Quote:
Originally Posted by Lillyput
Example

CheckBoxList1.Items[1].Enabled = false;

you can use the above code to disbale the items of a check box list


This clearly wouldn't work in a WinForms CheckedListBox as CheckedListBox1.Items[1] is of type "object" which has no Enabled property.

There's no built in way of doing it, but you can work around it with by adding the specific item with CheckState.Indeterminate. This "looks" like it's checked and disabled. However, as it isn't really disabled, you'll need to handle the ItemCheck event and stop the user from changing the checked state.

Reply With Quote
  #5  
Old September 7th, 2007, 05:39 AM
greystock greystock is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 1 greystock User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 11 sec
Reputation Power: 0
Disabling items in a checkedListBox

Here is some sample code that can be used in the ItemCheck event of a CheckedListBox to make items disable like...


try
{
if (e.Index == 0 && e.NewValue == CheckState.Checked)
{
if (chkListBoxCategoris.SelectedValue.ToString() == "All")
{
for (int i = 1; i < chkListBoxCategoris.Items.Count; i++)
{
chkListBoxCategoris.SetItemCheckState(i, CheckState.Indeterminate);
}
}
}
else if (chkListBoxCategoris.GetItemCheckState(0) == CheckState.Checked)
{
if (e.Index != 0 && checkFlag == false)
{
if (e.CurrentValue == CheckState.Indeterminate)
{
e.NewValue = e.CurrentValue;
}
}
else if (e.Index == 0)
{
checkFlag = true;
for (int i = 1; i < chkListBoxCategoris.Items.Count; i++)
{
chkListBoxCategoris.SetItemCheckState(i, CheckState.Unchecked);
}
checkFlag = false;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}




Happy Coding...
Gokulan V

Reply With Quote
  #6  
Old August 20th, 2011, 03:59 AM
suman_2302 suman_2302 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 1 suman_2302 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 4 sec
Reputation Power: 0
Use MouseUp event and in that write

Chklst_Box.SetItemChecked(0, True)

Reply With Quote
  #7  
Old November 21st, 2011, 01:58 AM
Robert156 Robert156 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 4 Robert156 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 40 sec
Reputation Power: 0
Use MouseUp event and in that write

Chklst_Box.SetItemChecked(0, True)URL
URL

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Disabling an item in a checkedListBox C#


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap