如何加快清除TreeView中資料的時間 |
答題得分者是:careychen
|
aconxu
一般會員 發表:18 回覆:41 積分:11 註冊:2006-12-19 發送簡訊給我 |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><meta content="Word.Document" name="ProgId" /><meta content="Microsoft Word 11" name="Generator" /><meta content="Microsoft Word 11" name="Originator" /><link href="file:///C:\DOCUME~1\ZITO~1.CHE\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml>
Dear all , 想請問一下 切換不同的ComboBox->ItemIndex中 就需先把TreeView可是我發現TreeView->Items->Clear()好慢~ 資料的方法~ 謝謝~ |
aconxu
一般會員 發表:18 回覆:41 積分:11 註冊:2006-12-19 發送簡訊給我 |
|
careychen
尊榮會員 發表:41 回覆:580 積分:959 註冊:2004-03-03 發送簡訊給我 |
Hi, 試試加上 BeginUpdate 與 EndUpdate 試試
Treeview->Items->BeginUpdate(); TreeView->Items->Clear() TreeView->Items->EndUpdate(); ===================引 用 aconxu 文 章=================== 我發現 ~如果我點選TreeView的任一個node 再切換ComboBox->ItemIndex時 TreeView->Items->Clear() 速度就會變的很慢 如果沒有點選TreeView上的Node 就不會這樣~
------
價值的展現,來自於你用哪一個角度來看待它!! |
aconxu
一般會員 發表:18 回覆:41 積分:11 註冊:2006-12-19 發送簡訊給我 |
Dear careychen , 感謝你的回答~ 我試過後~一樣慢~ 我發現~只要我點選TreeView<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><meta content="Word.Document" name="ProgId" /><meta content="Microsoft Word 11" name="Generator" /><meta content="Microsoft Word 11" name="Originator" /><link href="file:///C:\DOCUME~1\ZITO~1.CHE\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml> 它會先把A刪除,然後Focus在B上~ 此時就會觸發TreeView的OnChange 然後再刪除B,Fcous在C上,又觸發TreeView的OnChange 所以會一直去執行TreeView的OnChange導至速度被拖慢 所以在載入資料到TreeView前要先把Node指定到最後一個~ 如些就不會一直進入OnChange if(TreeView->Selected!=NULL) { TreeView->Selected = TreeView->Items->Item[TreeView->Items->Count-1]; } |
careychen
尊榮會員 發表:41 回覆:580 積分:959 註冊:2004-03-03 發送簡訊給我 |
那既然如此,如在 Clear 的指令前先把 OnChange 的事件先清掉,等到 clear 完後,再把事件指定回來
如下的處理的方式,參考看看應該比指定最後一筆來的直覺一點吧 !!!??? Treeview->OnChange = nil ; // 抱歉我用 delphi ,不曉得 BCB 是用什麼 Treeview->Items->Clear(); Treeview->OnChange = this->TreeviewChange(); ===================引 用 aconxu 文 章=================== Dear careychen , 感謝你的回答~ 我試過後~一樣慢~ 我發現~只要我點選TreeView<meta content="Word.Document" name="ProgId" /><meta content="Microsoft Word 11" name="Generator" /><meta content="Microsoft Word 11" name="Originator" /><link href="file:///C:\DOCUME~1\ZITO~1.CHE\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /><style type="text/css"> <!-- /* Font Definitions */ @font-face {font-family:新細明體; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-alt:PMingLiU; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} @font-face {font-family:"\@新細明體"; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:新細明體; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:18.0pt;} div.Section1 {page:Section1;} --></style>的Node再切換ComboBox時~ <meta content="Word.Document" name="ProgId" /><meta content="Microsoft Word 11" name="Generator" /><meta content="Microsoft Word 11" name="Originator" /><link href="file:///C:\DOCUME~1\ZITO~1.CHE\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml" rel="File-List" /><style type="text/css"> <!-- /* Font Definitions */ @font-face {font-family:新細明體; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-alt:PMingLiU; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} @font-face {font-family:"\@新細明體"; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:新細明體; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --></style><span lang="EN-US" type="text/css"> <!-- /* Font Definitions */ @font-face {font-family:新細明體; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-alt:PMingLiU; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} @font-face {font-family:"\@新細明體"; panose-1:2 2 3 0 0 0 0 0 0 0; mso-font-charset:136; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:3 137232384 22 0 1048577 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:新細明體; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:18.0pt;} div.Section1 {page:Section1;} --></style><br />一開始是點選在A上,切換ComboBox->ItemIndex時 它會先把A刪除,然後Focus在B上~ 此時就會觸發TreeView的OnChange 然後再刪除B,Fcous在C上,又觸發TreeView的OnChange 所以會一直去執行TreeView的OnChange導至速度被拖慢 所以在載入資料到TreeView前要先把Node指定到最後一個~ 如些就不會一直進入OnChange if(TreeView->Selected!=NULL) { TreeView->Selected = TreeView->Items->Item[TreeView->Items->Count-1]; }
------
價值的展現,來自於你用哪一個角度來看待它!!
編輯記錄
careychen 重新編輯於 2008-12-03 20:44:01, 註解 無‧
|
aconxu
一般會員 發表:18 回覆:41 積分:11 註冊:2006-12-19 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |