Hallo,
ich beschäftige mich zur Zeit mit dem VirtualStringTree von M.Lischke.
Im Internet habe ich ein Beispiel gefunden, das ein ClientDataSet
als Verbindung zu einer Datenbank benutzt.
Ich versuche nun mit ADOConnection und BetterADODataSet eine
Verbindung zu einer Access Datenbank herzustellen.
Das Problem liegt in der Methode FindKey, die von ADO nicht
unterstützt wird. Mit SEEK habe ich es bereits versucht, bekomme aber nur leere Datensätze. IndexName habe ich gesetzt, CommandType=cmdTableDirect, CursorLocation=clUseServer und
CursorType=ctKeySet.
So funktionierts mit dem ClientDataSet (cds):
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: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126:
| ------------------------------------------------------ type
TBasicNode = class protected FCaption : shortstring; FID : longint; FImageIndex : longint; FHasChanged : boolean;
public constructor Create( const sCaption : shortstring; const iID, iIndex: longint);
property Caption : shortstring read FCaption write FCaption; property ID : longint read FID write FID; property ImageIndex : longint read FImageIndex write FImageIndex; property HasChanged : boolean read FHasChanged write FHasChanged; end;
TBasicNodeAdd = class(TBasicNode) protected FJobTitle : shortstring; FAdd1 : shortstring; FAdd2 : shortstring; FAdd3 : shortstring;
public property Add1 : shortstring read FAdd1 write FAdd1; property Add2 : shortstring read FAdd2 write FAdd2; property Add3 : shortstring read FAdd3 write FAdd3; property JobTitle : shortstring read FJobTitle write FJobTitle; end;
PTreeData = ^TTreeData; TTreeData = record FObject : TBasicNode; end; --------------------------------------------------- constructor TBasicNode.Create( const sCaption : shortstring; const iID, iIndex: longint); begin inherited Create; FCaption := sCaption; FID := iID; FImageIndex := iIndex; end;
const FLDN_CustNo = 0; FLDN_Company = 1; FLDN_Addr1 = 2; FLDN_Addr2 = 3; FLDN_City = 4; FLDN_State = 5; FLDN_Zip = 6; FLDN_Country = 7; FLDN_Phone = 8; FLDN_FAX = 9; FLDN_TaxRate = 10; FLDN_Contact = 11; FLDN_LastInvoiceDate = 12; ---------------------------------------------------
procedure TfrmVTDBExample.VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var Text: WideString); var Data : PTreeData; FObject : TBasicNodeAdd; iLevel : integer; begin Text := ''; Data := Sender.GetNodeData(Node); if Assigned(Data) and (Data.FObject <> nil) then with Data.FObject do begin iLevel := Sender.GetNodeLevel( Node );
case Column of 0: begin case TextType of ttNormal: begin if iLevel = 0 then begin Text:=Caption end else begin if cds.FindKey([ID]) then with cds do Text := Trim( Fields[ FLDN_Addr1 ].AsString + ' ' + Fields[ FLDN_Addr2 ].AsString + ' ' + Fields[ FLDN_City ].AsString + ' ' + Fields[ FLDN_State ].AsString + ' ' + Fields[ FLDN_Zip ].AsString + ' ' + Fields[ FLDN_Country ].AsString ); end; end; ttStatic: begin Text := ''; end; end; end;
1: begin FObject := TBasicNodeAdd( Data.FObject ); case TextType of ttNormal: begin if (iLevel = 0)and cds.FindKey([ID]) then with cds do Text := Fields[ FLDN_Contact ].AsString; end; end; end;
2: begin if TextType = ttNormal then Text := ' '; end;
end; end; end; |
Moderiert von
Motzi: Code- durch Delphi-Tags ersetzt.