473,587 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checked listbox check all

After I fill checked listbox with data, I would like to checked all items in
list ?

Hrcko
Nov 17 '05 #1
3 35909
You can actually set the check state while you're adding the item(s), in
code.

this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString(), CheckState.Chec ked);
}
this.checkedLis tBox1.EndUpdate ();

If you really need to set all the check states after you have added the
items, then you can use the SetItemChecked method.

this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString());
}
for (int x = 0; x < this.checkedLis tBox1.Items.Cou nt; x++)
{
this.checkedLis tBox1.SetItemCh ecked(x, true);
}
this.checkedLis tBox1.EndUpdate ();

--
Tim Wilson
..Net Compact Framework MVP

"Hrvoje Voda" <hr*********@lu atech.com> wrote in message
news:d5******** **@ss405.t-com.hr...
After I fill checked listbox with data, I would like to checked all items in list ?

Hrcko

Nov 17 '05 #2
What should I put instead of x<25?

I tried listBox.Items.C ount but it doesn't work!

Hrcko
"Tim Wilson" <TIM(UNDERSCORE )WILSON(AT)ROGE RS(PERIOD)COM> wrote in message
news:em******** ******@tk2msftn gp13.phx.gbl...
You can actually set the check state while you're adding the item(s), in
code.

this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString(), CheckState.Chec ked);
}
this.checkedLis tBox1.EndUpdate ();

If you really need to set all the check states after you have added the
items, then you can use the SetItemChecked method.

this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString());
}
for (int x = 0; x < this.checkedLis tBox1.Items.Cou nt; x++)
{
this.checkedLis tBox1.SetItemCh ecked(x, true);
}
this.checkedLis tBox1.EndUpdate ();

--
Tim Wilson
.Net Compact Framework MVP

"Hrvoje Voda" <hr*********@lu atech.com> wrote in message
news:d5******** **@ss405.t-com.hr...
After I fill checked listbox with data, I would like to checked all items

in
list ?

Hrcko


Nov 17 '05 #3
I'm was just loading the CheckedListBox with some data. So you can either
set the check state when you're adding the items to the Items collection or
loop through and set them afterwards. There should be nothing wrong with
"checkedListBox 1.Items.Count" (of course, insert the name of your control).

--
Tim Wilson
..Net Compact Framework MVP

"Hrvoje Voda" <hr*********@lu atech.com> wrote in message
news:d5******** **@ss405.t-com.hr...
What should I put instead of x<25?

I tried listBox.Items.C ount but it doesn't work!

Hrcko
"Tim Wilson" <TIM(UNDERSCORE )WILSON(AT)ROGE RS(PERIOD)COM> wrote in message
news:em******** ******@tk2msftn gp13.phx.gbl...
You can actually set the check state while you're adding the item(s), in
code.

this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString(), CheckState.Chec ked);
}
this.checkedLis tBox1.EndUpdate ();

If you really need to set all the check states after you have added the
items, then you can use the SetItemChecked method.

this.checkedLis tBox1.BeginUpda te();
for (int x = 0; x < 25; x++)
{
this.checkedLis tBox1.Items.Add (x.ToString());
}
for (int x = 0; x < this.checkedLis tBox1.Items.Cou nt; x++)
{
this.checkedLis tBox1.SetItemCh ecked(x, true);
}
this.checkedLis tBox1.EndUpdate ();

--
Tim Wilson
.Net Compact Framework MVP

"Hrvoje Voda" <hr*********@lu atech.com> wrote in message
news:d5******** **@ss405.t-com.hr...
After I fill checked listbox with data, I would like to checked all
items in
list ?

Hrcko



Nov 17 '05 #4

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

Similar topics

3
1471
by: touf | last post by:
Hi, I've a Tabcontrol with many tabpages, in each one I've a checked listBox. The problem is that when I check items in listBox and go to an other page I lost the check (when i return to my tabbpage I find all items Unchecked) How can I resolve this . Thanks.
3
2900
by: Dean Slindee | last post by:
In a checked listbox, I am allowing drag/drop of the items within (resequencing). Problem is, when dropping a checked item, the checked state always reverts to unchecked (unwanted). Anyone know how to set the checked state of a checked listbox item in code. Here is the drag/drop code, which works fine, except for unchecking the dropped...
2
1401
by: alex | last post by:
Hi, is there a way to a) dissable a particular item in the checked listbox. i.e. I dont want users to change its state b) to change the font color/property of one item in the checked list box. Thanks a lot Alex
2
1145
by: Nathan | last post by:
How do you set an checked listbox item to be checked using code? Can't seem to find a method for doing that.
1
7013
by: Dennis | last post by:
I have a checked list box and am trying to use the SetItemCheck method as follows: mylistbox.SetItemChecked(indextoset, True) It seems to have no effect and the display does not show the box as checked. I've tried SetItemCheckedState with the same results using CheckState.Checked. Is this a bug in the checked listbox? It's driving me...
10
3858
by: dm1608 | last post by:
Hi, all. I have a requirement for one of my programs to have a "Checked Listbox" that contains a list of all my local/remote drives. I woudl like users to click one or more drives that I need to search for particular files. Can anyone tell me how to implement this in .NET 2.0 using VB or C#?
1
7055
by: jcrouse | last post by:
I am looping throught the items in a checked list box. If it helps, all of the items are checked. If I string of text matches a certain criteria I would like to change it's text color to red. I know this is incorrect, but something like so: If clbFinalList.Items(intLoopCount) = strBadA(x) Then clbFinalList.Items(x).forecolor = Color.Red...
0
1172
by: prisesh26 | last post by:
i need to have a checked listbox column in my datagrid. how to do,....plz help me
1
2007
by: sherifffruitfly | last post by:
Hi, I've got a checked list box, and a "go' button on the form. Each item in the checked list box is associated with a program (say notepad, calc, etc.). When the user clicks "go", every item that is checked is to be run. I'm looking for an elegant and extensible way to do this. I'm currently using an if block, which just seems silly to...
0
7918
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6621
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.