如何為DBGrid.Column 加一個屬性?? |
尚未結案
|
jeffreck
高階會員 發表:247 回覆:340 積分:197 註冊:2003-01-23 發送簡訊給我 |
|
Mickey
版主 發表:77 回覆:1882 積分:1390 註冊:2002-12-11 發送簡訊給我 |
jeffreck 你好: 同 ClassName 繼承, 參考看看:
type TColumn=class(DBGrids.TColumn) private FNewProp: boolean; published property NewProp: boolean read FNewProp write FNewProp default True; end; TForm1 = class(TForm) DBGrid1: TDBGrid; Table1: TTable; DataSource1: TDataSource; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if TColumn(DBGrid1.Columns[0]).NewProp then ShowMessage('New Property Add In.'); end;發表人 - Mickey 於 2004/07/01 23:37:53 |
jeffreck
高階會員 發表:247 回覆:340 積分:197 註冊:2003-01-23 發送簡訊給我 |
謝謝 Mickey 版主,
原來還可以這樣子作,太神了
但我把它寫成VCL 但沒看到新加的屬性??
請教我那錯了
unit dbgrid1; interface uses SysUtils, Classes, Controls, Grids, DBGrids; type TColumn=class(DBGrids.TColumn) private FNewProp: boolean; FJFAddNewEnabled :Boolean; published property NewProp: boolean read FNewProp write FNewProp default True; Property JFAddNewEnabled : Boolean Read FJFAddNewEnabled Write FJFAddNewEnabled; end; Tdbgrid1 = class(TDBGrid) private { Private declarations } protected { Protected declarations } public { Public declarations } published { Published declarations } end; procedure Register; implementation procedure Register; begin RegisterComponents('JFControls', [Tdbgrid1]); end; end.謝謝前輩!! |
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
Your modification will work in runtime, but not in design mode. If you want see it in IDE, you need to create a NEW TColumn type (e.g. TMyColumn) and make your TDBGrid1 using the new TMyColumn... well... the component/property editors.... not an easy job.
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |