Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Komponente Stringgrid mit ComboBox (https://www.delphipraxis.net/174280-komponente-stringgrid-mit-combobox.html)

Bummi 14. Apr 2013 16:53

AW: Komponente Stringgrid mit ComboBox
 
Liste der Anhänge anzeigen (Anzahl: 1)
Ich habe hier Zuhause leider nur ein 2010 er Delphi und hier funktioniert es problemlos. Falls sich niemand anderes findet um zu suchen, kann ich es morgen im Büro an einer VM mit D7 versuchen.

EDIT:

Läuft auch unter D7 problemlos, dass der Beispielcode nur bei Column eine "Combobox" anzeigt hast Du gesehen?
Delphi-Quellcode:
 if ACol = 2 then .....

Ginko 15. Apr 2013 12:37

AW: Komponente Stringgrid mit ComboBox
 
Zitat:

Zitat von Bummi (Beitrag 1211465)
Läuft auch unter D7 problemlos, dass der Beispielcode nur bei Column eine "Combobox" anzeigt hast Du gesehen?
Delphi-Quellcode:
 if ACol = 2 then .....

Ja, ich habe alle Felder durchprobiert, dann muss es wohl was mit meiner Delphi Insatllation zu tun haben, obwohl ich es einmal unter Virtualbox und einmal in einer echten XP-Installation versucht hatte.

Naja ich werd dann wohl mit der Version unten vorlieb nehmene müssen und auf die flexiblere Laufzeiterstellung verzichten...
Aber was gut ist, die Version läuft auch unter Lazarus.
Trotzdem Danke für die Antworten.

Delphi-Quellcode:
{ StringGrid mit ComboBox }

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var
  CRect:TRect;
begin
  if(ACol=1)then
  begin
    CRect:=StringGrid1.CellRect(ACol, ARow);
    inc(CRect.Left, StringGrid1.Left+2);
    inc(CRect.Right, StringGrid1.Left+2);
    inc(CRect.Top, StringGrid1.Top+2);
    inc(CRect.Bottom, StringGrid1.Top+2);
    ComboBox1.BoundsRect:=CRect;
    ComboBox1.Visible:=true;
    ComboBox1.ItemIndex:=integer(StringGrid1.Objects[ACol, ARow])-1;
  end
    else ComboBox1.Visible:=false;
end;


procedure TForm1.StringGrid1Exit(Sender: TObject);
begin
  if not(ActiveControl=ComboBox1)then
  begin
    ComboBox1.Visible:=false;
    StringGrid1.Selection:= TGridRect(Rect(-1, -1, -1, -1));
  end;
end;


procedure TForm1.ComboBox1Exit(Sender: TObject);
begin
  if not(ActiveControl = StringGrid1)then
  begin
    ComboBox1.Visible:= false;
    StringGrid1.Selection:= TGridRect(Rect(-1, -1, -1, -1));
  end;
end;


procedure TForm1.StringGrid1TopLeftChanged(Sender: TObject);
var
  GRect:TGridRect;
begin
  ComboBox1.Visible:= false;
  GRect:= StringGrid1.Selection;
  if(GRect.Left = 0) and (GRect.Right = 0)then
    begin
    inc(GRect.Left, 1);
    inc(GRect.Right, 1);
    end;
  StringGrid1.Selection:=GRect;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:00 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz