473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

CheckListBox

Does anyone know how to get the index of an item checked and then check it
if it is unchecked?
Nov 15 '05 #1
3 8683
Not sure what your asking here. Why would you see if an item is checked,
then check it if it is not. That doesn't make sense.

Anyways,to get the selected index of an item in the collection.

int index;
index = checkedListBox1.SelectedIndex;

TJ. Reardon

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #2
Hmm.. That's kind of a strange question..
You say get the index of an item checked, then check it
if it is unchecked? The only way I can interpret this is:

Get the index of an item TO SEE IF IT IS checked, then
check it if not.

There are ways to do that, but my experiences with the
CheckListBox control are not necessarily good ones. I'm
still hoping that I can find a better way than what I have
written to manipulate that control.

Now, get this:

I wrote an application that was just perfect for the CLB
control, and it worked great. That is, until I started to
add options that I would like to have. What I wanted to
do was generate a set of data, populate the CLB with it,
and then (at my leisure) check the ones I wanted to keep
OR check the ones I wanted to discard. When the list is
very large, sometimes it's handier to check the ones you
want, and other times it's handier to check the ones that
you DON'T want. So, after I had checked either, I wanted
to write a routine to get rid of either the checked or the
unchecked. I went through all of the methods, properties,
etc. for hours without finding a simple way to do this. At
the end, I had to write some pretty complicated
algorithms to update the CLB with the items left from
either checked or unchecked. It wasn't fun and took a
very long time to figure out since there are no easy
built-in methods to do this. I did it, though, and you as
well might find that sometimes you have to do it the
hard way. I'm still thinking about publishing those
algoritms though, but I've been holding out just in case
there IS a simpler way to do it!
"john sutor" <john_sutor@NOSPAM> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Does anyone know how to get the index of an item checked and then check it
if it is unchecked?

Nov 15 '05 #3
Hi,

Does anyone know how to get the index of an item checked and then check it
if it is unchecked?


I am afraid that your question is a little bit unclear (if you get the
index of a checked item, it doesn't make sense to verify if it is
unchecked, because you selected it to be checked).
Anyway, here a sample of how you could check an item if it was unchecked.

if (!this.checkedListBox1.GetItemChecked(index))
this.checkedListBox1.SetItemChecked(index, true);
Adrian Vinca [MSFT], Developer Division
--------------------------------------------------------------------
This reply is provided "AS IS", without warranty (express or implied).

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ncookson | last post by:
I am trying to add a caption or title to the box drawn around a checklistbox and having no luck. Is there a way to do this? I am using python 2.3.4 and wxPython 2.5 on a windows platform. Noel
5
by: Bernie Yaeger | last post by:
Is there any way to get a listbox or a checklistbox behave in an autocomplete manner, such that given 'two', 'three', 'water', 'them' would bring the selection to 'two' (not 'water') when I key in...
0
by: Marshal Antony | last post by:
I need to use a CheckListBox control with a scroll bar in ASP.NET.The server control doesn't have a scroll bar. Any help is appreciated. Marshal Antony
3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
1
by: comic_rage | last post by:
Hi, I created a checkListBox to allow the user to select and place a check next to multiple items in the GUI. I would like to add a 2 column where the first column show the description of the...
2
by: Mike Kim | last post by:
hi all, i have a checklistbox populated with about 50 items from database. and on the same form, i added to button to do the following. if you click this button, i want to have all items in the...
0
by: Ville Mattila | last post by:
Dear readers, I've some problems with the data binding of the checklistbox control. I'm using it with user preferences that are stored in a XML File. Information from the file is fetched with...
1
by: obrienkev | last post by:
Hi, I want to mark the CheckListBox items as Checked based on a database query. So the CheckListBox items should be checked if each item matches fundsAffected field from the below query... ...
3
by: obrienkev | last post by:
Hi all, How do I mark an item in a checklistbox as checked based on a condition? e.g. if(x=1) { // SET a ChecklistBox Item as Checked }
3
by: khalidjan9 | last post by:
I have data in an arraylist and i want to add data to checklist box on runtime and i also want to display a textbox besides it so that i get the comments example : checklistbox "text" textbox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.