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
| procedure TForm1.Button1Click(Sender: TObject);
var B : TContainedBindComponent;
C : TLinkGridToDataSourceColumns;
ib,ic : integer;
begin
for ib:=0 to BindingsList1.BindCompCount-1 do
begin
B:=BindingsList1.BindComps[ib];
if (B.ControlComponent.ClassType.ClassParent.ClassNameIs('TCustomGrid')) then
begin
if TLinkGridToDatasource(B).Columns.Count=0 then
begin
Memo1.Lines.Add('No columns defined');
{todo comment retrouver les colonnes dans ce cas ?}
end
else
// Colonnes définies au design
for ic := 0 to TLinkGridToDatasource(B).Columns.Count-1 do
begin
C :=TLinkGridToDataSourceColumns(TLinkGridToDatasource(B).Columns);
Memo1.lines.add(c[ic].MemberName+' '+B.Index.ToString);
end;
end;
end;
end;
function TForm1.FieldNameOfGridCol(const Grid: TcustomGrid;
const col: Integer): String;
var B : TContainedBindComponent;
ib : integer;
begin
for ib:=0 to BindingsList1.BindCompCount-1 do
begin
B:=BindingsList1.BindComps[ib];
if (B.ControlComponent=Grid) then
try
result:=TLinkGridToDataSourceColumns(TLinkGridToDatasource(B).Columns)[col].MemberName;
break;
except
result:='';
end;
end;
end; |
Partager