0

This for loop below sets 5 checkboxes in a checkedListBox. What I wonder is that when running the code below, 5 checkboxes is created and the checkboxes are "unchecked".
What I am wondering is how it is possible to make these 5 created checkboxes "checked" and how it is possible to set a "string" after each checkedbox, for ex: Word. So if 'v' is the checkbox. The example would look like this:

v Word
v Word
v Word
v Word
v Word

for(int i = 0; i < 5; i++)

{
	 CheckedListBox1->Items->Add(CheckedListBox1->CheckOnClick);
}
1
Contributor
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Jennifer84
0

I found out that this code do check all boxes. What I might wonder is how to put a "string" after a checkedBox.

for(int i = 0; i < 5; i++)

{
    CheckedListBox1->Items->Add(CheckedListBox1->CheckedItems);
				
}
 
for(int i = 0; i < 5; i++)

{
    CheckedListBox1->SetItemCheckState(i, CheckState::Checked);
}
0

I found a solution like this:

checkedListBox1->Items->Clear();
for(int i = 0; i < 5; i++)

{
				
	checkedListBox1->Items->Add("Word");
				
				
}



for(int i = 0; i < 5; i++)

{
				 				
	checkedListBox1->SetItemCheckState(i, CheckState::Checked);
				
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.