Autor Beitrag
Sven
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Mo 26.04.04 10:24 
Zuerst der Code:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
unit QDbfStdCtrls;

interface

uses
  Windows, Messages, SysUtils, Classes, QControls, QStdCtrls, QMask,
  QxDatabase, DesignEditors, DesignIntf;

type
  TBDFEdit = class(TCustomMaskEdit)
  private
    FDatabase   : TQDatabase;
    FField      : string;
    FFieldList  : TStringList;
  protected
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property DataSource: TQDatabase read FDatabase write FDatabase;
    property DataField: string read FField write FField;
  end;

  TFieldProperty = class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValues(Proc: TGetStrProc); override;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterPropertyEditor(TypeInfo(string), TBDFEdit, 'DataField', TFieldProperty);
  RegisterComponents('ABase', [TBDFEdit]);
end;

(******** TBDFEdit ********)

constructor TBDFEdit.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FFieldList := TStringList.Create;
  FFieldList.Add('Feld 1');
  FFieldList.Add('Feld 2');
  FFieldList.Add('Feld 3');
end{ Create }

destructor TBDFEdit.Destroy;
begin
  FFieldList.Free;
  inherited Destroy;
end{ Destroy }

(******** TFieldPropertyEditor ********)

function TFieldProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paSortList];
end{ GetAttributes }

procedure TFieldProperty.GetValues(Proc: TGetStrProc);
begin
  //Beispielwerte zum Testen
  Proc('Feld 1');
  Proc('Feld 2');
  Proc('Feld 3');

end{ GetValues }

end.

Und nun die Frage :)

Wie stelle ich es an, das ich innerhalb von TFieldProperty.GetValues auf die StringListe aus TBDFEdit (FFieldList) zugreifen kann?

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows
Sven Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Mo 26.04.04 10:37 
Ok, danke. Problem gelöst.

Hier der Lösungscode:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TFieldProperty.GetValues(Proc: TGetStrProc);
  var i : integer;
begin
  with (GetComponent(0as TBDFEdit).FFieldList do
    for i := 0 to Count-1 do Proc(Strings[i]);
end{ GetValues }


Moderiert von user profile iconUdontknow: Delphi-Tag korrigiert.

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows