Ver Mensaje Individual
  #1  
Antiguo 04-08-2022
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Ubicación: Toledo - España
Posts: 1.418
Reputación: 21
Angel.Matilla Va por buen camino
Comportamiento extraño de TVirtualStringTree

Me está ocurriendo algo que no soy capaz de comprender. Tengo este TVST en un formulario.

y en el evento OnChecked tengo puesto este código:
Código:
int nRecibo = 0;
double nImporte = 0;

Button1->Enabled = false;
Button2->Enabled = false;
Nodo = Lista->GetFirst();
while (Nodo != NULL)
{
     if (!Lista->HasChildren[Nodo] && (Lista->CheckState[Nodo] == csCheckedNormal || Lista->CheckState[Nodo] == csCheckedPressed))
     {
          nRecibo  = nRecibo + ((PTreeSelRec)Lista->GetNodeData(Node))->Recibos;
          nImporte = nImporte + ((PTreeSelRec)Lista->GetNodeData(Nodo))->Importe;
     }
     Nodo = Lista->GetNext(Nodo);
}

Button1->Enabled = fNueRec->Button1->Tag != 3 ? nRecibo > 0 && nImporte > 0 : nRecibo > 0 && nImporte > 0 && RadioGroup1->ItemIndex >= 0;
Button2->Enabled = Button1->Enabled;
HeaderControl1->Sections->Items[1]->Text = nRecibo > 0 ? (String)FormatFloat("'Recibos: '###,##0", nRecibo) : (String)"";
HeaderControl1->Sections->Items[2]->Text = nImporte > 0 ? (String)FormatFloat("'Importe: '#,###,##0.00 €", nImporte) : (String)"";
Lo que me está ocurriendo es que seleccione el nodo que seleccione el evento se ejecuta tantas veces como nodos tenga el TVST, en este caos hay 37 nodos y pasa 37 veces por el OnChecked. ¿Alguno me puede explicar por qué?
Responder Con Cita