線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1453
推到 Plurk!
推到 Facebook!

Table -> StringGrid 問題

缺席
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-11-27 09:41:54 IP:61.218.xxx.xxx 未訂閱
以下作法 速度很慢 若有1000筆 以上都需花十幾分鐘以上 請問有什麼方法能較快 從 Table 載入 StringGrid for i:=0 to Table2.RecordCount-1 do begin StringGrid1.RowCount:= j 1; StringGrid1.Cells[0,j]:= Table2.FieldByName('DIFF').Asstring; StringGrid1.Cells[1,j]:= Table2.FieldByName('X1').Asstring; StringGrid1.Cells[2,j]:= Table2.FieldByName('Y1').Asstring; StringGrid1.Cells[3,j]:= Table2.FieldByName('X2').Asstring; StringGrid1.Cells[4,j]:= Table2.FieldByName('Y2').Asstring; StringGrid1.Cells[5,j]:= Table2.FieldByName('P').Asstring; StringGrid1.Cells[6,j]:= Table2.FieldByName('備註').AsString; StringGrid1.Row:=j; if PDM.Table2.FieldByName('P').AsBoolean =TRUE then INC(g) else INC(b); if i< (Table2.RecordCount-1) then Table2.Next; inc(j); application.ProcessMessages; end;
------
︿︿
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-11-27 10:03:41 IP:147.8.xxx.xxx 未訂閱
Filling string grid is very slow, there exist several free string grid replacement which should speed up the process. However, another way is to NOT filling the cells. Making use of the OnDrawCell event will be faster since there is no need to fetch and fill all records at once, but you need to handle all the drawing yourself then.
chih
版主


發表:48
回覆:1186
積分:639
註冊:2002-04-02

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-11-27 10:47:31 IP:211.74.xxx.xxx 未訂閱
既然是連接Table..有沒有可能考慮用DBGrid連接.. 因為不知道你的設計或許有特殊用途.. 僅供參考....
引言: 以下作法 速度很慢 若有1000筆 以上都需花十幾分鐘以上 請問有什麼方法能較快 從 Table 載入 StringGrid
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-11-27 12:41:46 IP:147.8.xxx.xxx 未訂閱
I think you need to set the Index of the table (i.e. DataSet) to have a proper order.
chih
版主


發表:48
回覆:1186
積分:639
註冊:2002-04-02

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-11-27 13:04:00 IP:211.74.xxx.xxx 未訂閱
應該是不會有這種情形吧.. 你要不要把你的Table格式跟程式碼post上來... 這樣比較清楚ㄋ...
引言: 本來 我也是 用 DBGrid 連接 但 我在 TABLE 新增一筆資料 DBGrid 卻未照順序顯示出來 資料順序都亂跳 所以才改成 STRINGGRID
richcomp
中階會員


發表:18
回覆:66
積分:51
註冊:2002-10-18

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-11-27 17:39:49 IP:61.177.xxx.xxx 未訂閱
使用DBGrid,將dataset中的Indexfieldname設置為欲排序的欄位,資料就可以排序了,後台數據庫中的INDEX並不是資料存儲順序(SQL SERVER、ORACLE都不是)
系統時間:2024-05-05 18:03:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!