How to load array items into list box?

Asked

Viewed 272 times

1

I have a TCheckListBox and when it is checked I store the options in an Array. I need that, by clicking on a "List" button, the Array elements (options marked in the TCheckListBox) are listed on TListBox.

Must be something like this:

inserir a descrição da imagem aqui

1 answer

1

For that we will go all the way TCheckListBox looking for the marked items, and we add one by one in the TListBox.

Follows procedure:

void __fastcall frmTeste::btnTesteClick(TObject *Sender)
{
  ListBox1->Clear(); //Limpando a Lista
  for (int i = 0; i < CheckListBox1->Count; i++)
  {
    if (CheckListBox1->Checked[i]) //Para cada 1 que estiver maarcado...
      ListBox1->Items->Add(CheckListBox1->Items->Strings[i]); //...Adiciona na lista
  }
}
  • I had tried this way, but he won’t let me use the Checklistbox in my button event. Error: Undefined Symbol 'clbGabarito'. NOTE: clbGabarito is my checklistbox.

  • Put your code to the question!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.