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

請問是否能對Grid做動態產生Column的方法

答題得分者是:FrederickPau
skurama
中階會員


發表:88
回覆:127
積分:73
註冊:2002-07-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-11-13 13:55:22 IP:61.219.xxx.xxx 未訂閱
接著之前所做的有關時間排程的程式 有時候發生Grid的Column數量不夠 目前我是用新增一大堆,將不要的隱藏起來~~~ 請問是不是有什麼方法可以動態產生Column, 以下是我目前的方法,但並沒有產生新的Column public ColumnA : TColumn; procedure TForm1.Button1Click(Sender: TObject); begin AColumn := TColumn.create(self); <--會錯 AColumn.visible :=true; AColumn.Caption := 'test'; end; 而且也不知道如何將其加入到我要的Grid內!!! ---------------- 平身進退如殘竹, 一睨人才到處是, 獨被蒼天橫冷劍, 何生英雄來殘我。 ----------------
------
----------------
初出芧房程設師,
左鍵右鼠寫程式,
日扣夜寫眼框溼,
望能早成系分師。
----------------
william
版主


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-11-13 14:05:40 IP:147.8.xxx.xxx 未訂閱
There should be some 3rd party VCL letting you to insert a column at run time, but the standard grid/string grid won't let you do it. However, there is a way to make it look like a column is inserted: Draw everything in the OnDrawCell event and do not rely on the string grid to draw the text content (e.g. store the data internally in a list). When a new column is needed, change the ColCount and do an Invalidate for the grid, which in turn trigger the OnDrawCell event and hence you can draw the cells.
FrederickPau
資深會員


發表:4
回覆:161
積分:268
註冊:2002-11-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-11-13 14:23:44 IP:61.228.xxx.xxx 未訂閱
public ColumnA : TColumn;    procedure TForm1.Button1Click(Sender: TObject); begin ColumnA := DBGrid1.Columns.Add; ColumnA.visible :=true; ColumnA.Caption := 'test'; end; 可以這樣試試
skurama
中階會員


發表:88
回覆:127
積分:73
註冊:2002-07-22

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-11-13 15:25:47 IP:61.219.xxx.xxx 未訂閱
Sorry~~~ 抱歉~~~ 我發現我用的元件不是標準元件TGrid (原本以為兩個的屬性一樣) 我是QuantumGird的dxDBGrid    可是dxdbgrid1.columns.add  <---並沒有這個屬性 不知道您是否是有用過這個元件~~~ ---------------- 平身進退如殘竹, 一睨人才到處是, 獨被蒼天橫冷劍, 何生英雄來殘我。 ----------------
------
----------------
初出芧房程設師,
左鍵右鼠寫程式,
日扣夜寫眼框溼,
望能早成系分師。
----------------
FrederickPau
資深會員


發表:4
回覆:161
積分:268
註冊:2002-11-04

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-11-13 17:23:01 IP:61.228.xxx.xxx 未訂閱
嗯 ... 我沒用過 ... 如果有需要 ... 給我連結, 我 DL 試看看
skurama
中階會員


發表:88
回覆:127
積分:73
註冊:2002-07-22

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-11-13 17:39:40 IP:61.219.xxx.xxx 未訂閱
http://www.devexpress.com/downloads/vcl/pexpgrid.asp    好像可以下傳試用版    聽同學說好像Delphi有Quantum Grid這個元件 不過我沒有用過Delphi 6 如果沒有的話,或下傳的不能用的話 那我在試試好了~~~ 謝謝~~~ ---------------- 平身進退如殘竹, 一睨人才到處是, 獨被蒼天橫冷劍, 何生英雄來殘我。 ----------------
------
----------------
初出芧房程設師,
左鍵右鼠寫程式,
日扣夜寫眼框溼,
望能早成系分師。
----------------
系統時間:2024-04-29 1:43:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!