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);
}

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);
}

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);
				
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.