How to move items between 2 Treeview dynamically?

Asked

Viewed 173 times

0

I have a Treeview that receives as items the fields of a database. I wanted to link these fields to another Treeview that already has a predefined structure. It would be something like the image shows:

inserir a descrição da imagem aqui

Currently this link is done using to drag items from left to right.

1 answer

0

As my Treeview items on the right are fixed, I solved the problem by adding one at a time along with your child. Follow the code:

// Adding items to Treeview

TTreeNode *noPai;

noPai = trvDestino->Items->Add(NULL,"Matrícula");
trvDestino->Items->AddChild(noPai,trvOrigem->Items->Item[0]->Text);

noPai = trvDestino->Items->Add(NULL,"Unidade");
trvDestino->Items->AddChild(noPai,trvOrigem->Items->Item[1]->Text);

noPai = trvDestino->Items->Add(NULL,"Gabarito");
trvDestino->Items->AddChild(noPai,trvOrigem->Items->Item[2]->Text);

noPai = trvDestino->Items->Add(NULL,"Respostas");
for(int i=3;i< trvOrigem->Items->Count; i++){
  trvDestino->Items->AddChild(noPai,trvOrigem->Items->Item[i]->Text);
}

Browser other questions tagged

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