// написал простенький data-aware компонент
// на основе статьи MAKING DATA-AWARE CONTROLS
// данные он отображает
// а вот при смене позиции в TreeView текущая запись dataset не меняется
// Другими словами, сейчас нет отклика в dataset (смена текущей записи) при перемещении по treeview
//
destructor TRadDBList.Destroy;
begin
FDataLink.OnDataChange := nil;
FDataLink.Free;
inherited Destroy;
end;
function TRadDBList.ValidDataField: Boolean;
begin
Result := ValidDataSource and Assigned(DataSource.DataSet.FindField(DataField));
end;
function TRadDBList.ValidListField: Boolean;
begin
Result := ValidDataSource and Assigned(DataSource.DataSet.FindField(ListField));
end;
function TRadDBList.ValidDataSource: Boolean;
begin
Result := Assigned(DataSource) and Assigned(DataSource.DataSet)
end;
procedure TRadDBList.RefreshTree;
var
VOldPlace: TBookmark;
begin
if ValidDataSource and FDataLink.DataSet.Active
then
with FDataLink.DataSet do
begin
DisableControls;
FDataLink.FieldName := DataField;
if ValidDataField and ValidListField then
begin
VOldPlace := FDataLink.DataSet.GetBookmark;
Items.Clear;
First;
while not Eof do
begin
Items.Add(nil, FieldValues[ListField]);
Next;
end;
FDataLink.DataSet.GotoBookmark(VOldPlace);
end;
EnableControls;
end
else
begin
Enabled := False;
Items.Clear;
end;
end;
procedure TRadDBList.Set_DataField(Value: string);
begin
FDataLink.FieldName := Value;
end;
function TRadDBList.Get_DataField: string;
begin
Result := FDataLink.FieldName;
end;
procedure TRadDBList.Set_ListField(Value: string);
begin
FListField := Value;
end;
function TRadDBList.Get_ListField: string;
begin
Result := FListField;
end;
procedure TRadDBList.Set_DataSource(Value: TDataSource);
begin
FDataLink.DataSource := Value;
end;
function TRadDBList.Get_DataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
procedure TRadDBList.DataChange(Sender: TObject);
begin
end;
procedure TRadDBList.Change(Node: TTreeNode);
begin
{ call the Modified method }
inherited Change(Node); { call the inherited Change method }
end;
procedure Register;
begin
RegisterComponents('Radico', [TRadDBList]);
end;