全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1015
推到 Plurk!
推到 Facebook!

請問如何讓TStringGrid在插入資料時,將新資料放在第一行?

尚未結案
koanchen
一般會員


發表:4
回覆:4
積分:1
註冊:2004-01-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-01-02 11:38:16 IP:61.222.xxx.xxx 未訂閱
各位大大: 請問一下如何讓TStringGrid在插入資料時,將新資料放在第一行,其他的資料則順延往下一行,請問有什麼方法可以做到??
ying0515
中階會員


發表:90
回覆:168
積分:81
註冊:2003-01-04

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-01-02 11:51:45 IP:61.218.xxx.xxx 未訂閱
用DBGrid可能較好處理! Delphi follower
------
Delphi
海星
高階會員


發表:41
回覆:217
積分:106
註冊:2003-01-09

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-01-02 12:26:08 IP:61.218.xxx.xxx 未訂閱
用資料庫索引功能..Tquery的話SQL語法就使用 "DESC"關鍵字 TTable的話,就直接建立一個反方向的索引,並且使用這個索引檔.
海星
高階會員


發表:41
回覆:217
積分:106
註冊:2003-01-09

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-01-02 12:33:16 IP:61.218.xxx.xxx 未訂閱
抱歉..我剛看到最後一個人的回復,看到DBGrid.. 以為原作者要問DBGrid顯示. 文張貼出去後才看到第一篇文章原作者的文章, 如果TStringGrid 的話,就用一個迴圈,把每一行(N)內容往 N 1 行 copy, 並且把第一行清空這樣就可以在第一行輸入資料了. (希望這個方法不會太笨)
koanchen
一般會員


發表:4
回覆:4
積分:1
註冊:2004-01-02

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-01-06 15:13:39 IP:61.222.xxx.xxx 未訂閱
我曾用了下列的方法嘗試的解決可是會程式當掉 請各位大大幫我看看為什麼吧~ var cnt,i : integer; begin StringGrid1.RowCount := StringGrid1.RowCount 1; cnt := StringGrid1.RowCount; while (i >= 2 ) do begin StringGrid1.Cells[0,i] := StringGrid1.Cells[0,i-1]; StringGrid1.Cells[1,i] := StringGrid1.Cells[1,i-1]; StringGrid1.Cells[2,i] := StringGrid1.Cells[2,i-1]; StringGrid1.Cells[3,i] := StringGrid1.Cells[3,i-1]; i := i - 1; end; end;
00156
高階會員


發表:45
回覆:195
積分:112
註冊:2002-06-01

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-01-06 15:29:39 IP:61.56.xxx.xxx 未訂閱
引言: var cnt,i : integer; begin StringGrid1.RowCount := StringGrid1.RowCount 1; i := StringGrid1.RowCount-1; while (i >= 1 ) do begin StringGrid1.Cells[0,i] := StringGrid1.Cells[0,i-1]; StringGrid1.Cells[1,i] := StringGrid1.Cells[1,i-1]; StringGrid1.Cells[2,i] := StringGrid1.Cells[2,i-1]; StringGrid1.Cells[3,i] := StringGrid1.Cells[3,i-1]; i := i - 1; end; end;
系統時間:2024-04-24 13:43:03
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!