Einzelnen Beitrag anzeigen

hhcm

Registriert seit: 12. Feb 2006
Ort: Wegberg
309 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: TAdvStrinGrid mit ComboBox mehrere Spalten füllen

  Alt 22. Mär 2020, 08:17
Ich habe nicht gesagt das es nicht anders geht.
Was mit deinem Beispiel funktioniert ist folgendes.

Delphi-Quellcode:
procedure TFormx.sg2EditChange(Sender: TObject; ACol, ARow: Integer; Value: string);
var
  di: TDropDownItem;
  colIndex: Integer;
begin
  if ACol = 2 then
  begin
    sg2.GridDropDown.LookupColumn := 0;
    colIndex := sg2.GridDropDown.Items.IndexInColumn(0, Value);

    if colIndex > -1 then
    begin
      di := sg2.GridDropDown.Items[colIndex];
      sg2.Cells[3, ARow] := di.Text[1];
    end;
  end
  else if ACol = 3 then
  begin
    sg2.GridDropDown.LookupColumn := 1;
    colIndex := sg2.GridDropDown.Items.IndexInColumn(1, Value);

    if colIndex > -1 then
    begin
      di := sg2.GridDropDown.Items[colIndex];
      sg2.Cells[2, ARow] := di.Text[0];
    end;
  end;
end;
Ist als Showcase. Geht bestimmt elleganter.
Chris
  Mit Zitat antworten Zitat