Autor Beitrag
kandesbunzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116
Erhaltene Danke: 1


Delphi 7, XE2
BeitragVerfasst: Mo 21.12.20 20:53 
Hallo,

in einem StringGrid möchte ich ermitteln, sofern geklickt, welche Zelle angeklickt wurde (Einfachklick).

Bsp.: Der StringGrid1 wurde als 4 x 4 Grid deklariert. Wenn ich bspw. auf Zeile 2, Spalte 3 klicke, möchte ich diese Zelle in einer Auswerteprozedur 'weiterbearbeiten'.

Wie kann ich das anstellen? Meine Versuche mit der Ereignisauswertung 'OnClick' haben keine Reaktion gezeigt.

Danke!


Moderiert von user profile iconTh69: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mo 21.12.2020 um 20:04
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mo 21.12.20 21:09 
Wäre dann nicht OnSelectCell sinnvoller (also bei jedweder Aktivierung einer Zelle)?

Ansonsten kannst du doch direkt auch auf die StringGrid-Eigenschaften Col und Row zugreifen.
mandras
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 429
Erhaltene Danke: 107

Win 10
Delphi 6 Prof, Delphi 10.4 Prof
BeitragVerfasst: Do 24.12.20 00:24 
Beispiel: Im OnMouseDown-Event:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var C,R:integer;
    S:string;
begin
 StringGrid1.MouseToCell(X,Y, C,R);
 S:=format ('Spalte %d Zeile %d',[C,R]);
 MessageDLG (S, mtInformation, [mbOK] ,0);
end;

Für diesen Beitrag haben gedankt: kandesbunzler
kandesbunzler Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116
Erhaltene Danke: 1


Delphi 7, XE2
BeitragVerfasst: Mi 30.12.20 14:17 
Hat mit OnSelectCell funktioniert. Danke!