Board index » cppbuilder » TTreeView has a mind of its own...?
chapnospam
CBuilder Developer |
TTreeView has a mind of its own...?2004-02-29 02:34:50 PM cppbuilder21 After several hours of trying, I must write this here. I simply want the following: 1) The user is now navigating (with the keyboard) through the nodes of a TTreeView object. 2) The user finds a NODE and wishes to add a SYBIL to that node. Here my code: void __fastcall TForm1::tv1KeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { switch(Key) { case VK_INSERT: if(Shift.Contains(ssShift)) // NOT THIS CASE NOW { bCate=false; } else // the user ONLY pressed INSERT { TTreeNode *n; stCat *nw = new stCat; nw->tiesub='f'; nw->idsupra=((stCat*)(tv1->Selected)->Data)->idsupra; n=tv1->Items->AddObject(tv1->Selected,"newone",nw); n->Selected=true; n->EditText(); bCate=true; AddNodeToDatabase(n); } } } void __fastcall TForm1::tv1Edited(TObject *Sender, TTreeNode *Node, AnsiString &S) { S = AnsiUpperCase(S); } And here is what happens and why I must post this here and try to find somebody to help: The user presses insert and it goes into edit mode, HOWEVER function AddNodeToDatabase(n) IS EXECUTED BEFORE the function EditText() finishes. So, as a result of such strange behavior, the value of the node text is ALWAYS (in the database) "newone". In other words, my function AddNodeToDatabase(TTreeNode *n) is executed BEFORE the function n->EditText() finishes. I simply would like the program to allow the user to enter values for the labels of the nodes and after such actions have been committed, then commit them to the database, Impossible! Please, help! F J Fortuny |