55143681 Posted August 25, 2018 Share Posted August 25, 2018 Help: In my project ,I create a treeview dynamic,and when the tree created,I call UniTreeView3->FullExpand() to full expand the tree,but that not work.If I call UniTreeView3->FullExpand() in another buttonClick after the treeview is created,it works well,why? void __fastcall TMainForm::UniTabSheet5BeforeActivate(TObject *Sender, bool &AllowActivate) { //系统链接树节点 if(UniTreeView3->Items->Count>0) { //ShowMessage("None List"); return; } PMyRec MyRecPtrSite; //创建根 MyRecPtrSite = new TMyRec; MyRecPtrSite->nodeId=0; MyRecPtrSite->nodeName=""; UniTreeView3->Items->Clear(); TUniTreeNode *posSite;//=UniTreeView2->Items->AddChildObject(NULL,"",MyRecPtrGuide); //组建根目录下第一层节点 //一级机构 UniQuery5->Close(); UniQuery5->SQL->Clear(); UniQuery5->SQL->Add("select distinct(site_type) as siteType from site_info"); UniQuery5->Open(); while(!UniQuery5->Eof) { MyRecPtrSite = new TMyRec; MyRecPtrSite->nodeName=UniQuery5->FieldByName("siteType")->AsString; posSite=UniTreeView3->Items->AddChildObject(NULL,UniQuery5->FieldByName("siteType")->AsString,MyRecPtrSite); //二层节点 UniQuery4->Close(); UniQuery4->SQL->Clear(); UniQuery4->SQL->Add("select * from site_info where site_type=:w1 "); UniQuery4->ParamByName("w1")->Value=UniQuery5->FieldByName("siteType")->AsString; UniQuery4->Open(); while(!UniQuery4->Eof) { MyRecPtrSite = new TMyRec; MyRecPtrSite->nodeName="["+UniQuery4->FieldByName("site_name")->AsString+"]"+UniQuery4->FieldByName("site_url")->AsString; posSite=UniTreeView3->Items->AddChildObject(posSite,"["+UniQuery4->FieldByName("site_name")->AsString+"]"+UniQuery4->FieldByName("site_url")->AsString,MyRecPtrSite); posSite=posSite->Parent; UniQuery4->Next(); } // UniQuery5->Next(); } UniTreeView3->FullExpand(); } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 25, 2018 Share Posted August 25, 2018 Hi, Have you tried with ?! UniTreeView1.BeginUpdate; ... UniTreeView1.EndUpdate; UniTreeView1.FullExpand; Quote Link to comment Share on other sites More sharing options...
55143681 Posted August 27, 2018 Author Share Posted August 27, 2018 Hi, Have you tried with ?! UniTreeView1.BeginUpdate; ... UniTreeView1.EndUpdate; UniTreeView1.FullExpand; Sorry,that doesn't work.I put fullExpand in a RunOnce Timer event now。 Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 27, 2018 Administrators Share Posted August 27, 2018 Please use OnLoaded() event. Quote Link to comment Share on other sites More sharing options...
55143681 Posted September 3, 2018 Author Share Posted September 3, 2018 Please use OnLoaded() event. As you say,I put "UniTreeView1.FullExpand;" in OnLoaded,It works well ! Thanks a lot. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.