Будучи довольно сдержанным, чтобы изменять / поддерживать измененный код VCL / RTL, я нашел другой способ. Объявите следующее в интерфейсе вашего устройства:
interface
uses
...
;
type Tdbp = class(TDBCtrlGrid);
type tdbl = class(TDBLookupControl);
type
TForm4 = class(TForm)
...
DBCtrlGrid1: TDBCtrlGrid;
...
private
...
function FindLCB(DataFieldName: String): TDBLookupComboBox;
procedure FixDBLookupDataLinks;
public
...
end;
...and in your implementation:
----------
implementation
procedure TForm4.FormCreate(Sender: TObject);
begin
...
DBCtrlGrid1.DataSource := DataSource1;
FixDBLookupDataLinks;
end;
procedure TForm4.FixDBLookupDataLinks;
var
lcb: TDBLookupComboBox;
I,n: Integer;
MyDataLink: TDataLink;
ctl: TControl;
dbp: Tdbctrlpanel;
begin
dbp := Tdbp(DBControlGrid1).Panel;
for n := 0 to Pred(dbp.ControlCount) do
begin
ctl := dbp.Controls[n];
if ctl.ClassType = TDBLookupComboBox then
begin
lcb := TDBLookupComboBox(ctl);
lcb.ControlStyle := lcb.ControlStyle + [csReplicatable];
TDBL(lcb).ListLink.DataSourceFixed := False;
for I := 0 to Pred(lcb.ControlCount) do
begin
if lcb.Controls[I] is TPopupDataList then
begin
TDBL(lcb).ListLink.DataSourceFixed := False;
TDBL(lcb).DataLink.DataSourceFixed := False;
MyDataLink := TDataLink(lcb.Controls[I].Perform(CM_GETDATALINK, 0, 0));
if MyDataLink <> nil then
MyDataLink.DataSourceFixed := False;
MyDataLink.DataSource := nil;
end;
end;
end;
end;
end;
function TForm4.FindLCB(DataFieldName: String): TDBLookupComboBox;
var
i: Integer;
begin
Result := Nil;
for i := 0 to Pred(ControlCount) do
if Controls[i].ClassType = TDBLookupComboBox then
if TDBLookupComboBox(Controls[i]).DataField = DataFieldName then
begin
Result := TDBLookupComboBox(Controls[i]);
Break;
end;
end;