Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#7

Re: DBGrid ausgewähltes Feld vorne anzeigen

  Alt 22. Feb 2008, 09:10
Hallo Smiley,

das Verschieben eines Feldes im Gitter kannst du über eine private Methode organisieren:

Delphi-Quellcode:
procedure TDemoForm.Promote(ds: TDataSet; const fieldName: string);
var
  f: TField;
begin
  if (PromotedIndex > 0) and (PromotedIndex < ds.FieldCount) then
  begin
    ds.Fields[0].Index := PromotedIndex;
    PromotedIndex := 0;
  end;
  if fieldName <> 'then
  begin
    f := ds.Fields.FieldByName(fieldName);
    PromotedIndex := f.Index;
    f.Index := 0;
  end;
end;
PromotedIndex ist dabei eine private Variable vom Typ Integer, in der die alte Position des Feldes gespeichert wird.

Freundliche Grüße
  Mit Zitat antworten Zitat