Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   stringgrid fixedcol oder fixedrow klick (https://www.delphipraxis.net/181399-stringgrid-fixedcol-oder-fixedrow-klick.html)

davtix 11. Aug 2014 18:36

stringgrid fixedcol oder fixedrow klick
 
hi :) , wie kann ich per klick oder doppelklick die fixedRow oder fixedCol ansprechen

zum Bsp. für den inhalt eines stringgrid zu sortieren oder ähnliches...

DeddyH 11. Aug 2014 19:00

AW: stringgrid fixedcol oder fixedrow klick
 
Ein spontaner Ansatz:
Delphi-Quellcode:
procedure TFormTest.StringGridMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  ACol, aRow: integer;
begin
  if Button = mbLeft then
    begin
      StringGrid.MouseToCell(X, Y, ACol, ARow);
      if (ACol < StringGrid.FixedCols) or (ARow < StringGrid.FixedRows) then
        ShowMessage('Fixe Zelle');
    end;
end;

Volker Z. 11. Aug 2014 22:15

AW: stringgrid fixedcol oder fixedrow klick
 
Hallo,

vielleicht sollte man noch die -1 berücksichtigen, die in ACol und ARow geliefert wird, wenn der Klick etwas außerhalb des "tatsächlich gezeichneten" Grids liegt.
Delphi-Quellcode:
if (ACol > -1) and ((ACol < StringGrid.FixedCols) or (ARow < StringGrid.FixedRows)) then
  ShowMessage('Fixe Zelle')
Gruß

DeddyH 11. Aug 2014 22:35

AW: stringgrid fixedcol oder fixedrow klick
 
Einverstanden, aber wieso nur auf einer Achse?

Volker Z. 11. Aug 2014 22:42

AW: stringgrid fixedcol oder fixedrow klick
 
Hallo,

wenn der Klick außerhalb "tatsächlich gezeichneten" Grids liegt (egal welche Richtung), dann liefert ACol und ARow immer -1 (zumindest mit XE4 und vermutlich auch davor).

Gruß

DeddyH 11. Aug 2014 22:45

AW: stringgrid fixedcol oder fixedrow klick
 
Ich sollte mir wirklich abgewöhnen, am Smartphone zu antworten, das war mir später auch durch den Kopf geschossen, alles andere wäre ja auch Blödsinn :)

Volker Z. 11. Aug 2014 23:01

AW: stringgrid fixedcol oder fixedrow klick
 
Hallo,
Zitat:

alles andere wäre ja auch Blödsinn
Stimmt schon, vielleicht sollte man trotzdem (nur, um sicher zu gehen) auch noch die andere Richtung abfragen - man weiß nie :wink:

Gruß

davtix 12. Aug 2014 16:14

AW: stringgrid fixedcol oder fixedrow klick
 
uii, danke schön. :)

hab mir heut morgen auf m rad so überlegt das mit Mouse.CursorPos zu realisieren ... aber die ganze rechnerei ist bestimmt keine gute idee für die cpu ,oder??

jetzt muss ich nur noch so kleinen pfeil (für sortierung) auf die fixed col bringen ... könnt ich das mit (code unten) auch realisieren???

Code:
  if ( 4 = vari ) and (bearbMod = 1) and (MRow >= form5.StringGrid1.FixedRows) then begin
    form5.StringGrid1.Perform(WM_CANCELMODE, 0, 0);
    R := form5.StringGrid1.CellRect(MCol, MRow);
    org := form5.StringGrid1.ScreenToClient(form5.StringGrid1.ClientToScreen(R.TopLeft));
    with form5.ComboBox1 do begin
      SetBounds(org.X, org.Y, R.Right-R.Left, form5.Stringgrid1.Height);
      ItemIndex := Items.IndexOf(form5.StringGrid1.Cells[MCol, MRow]);
      Show;
      BringToFront;
      SetFocus;
      DroppedDown := true;
    end;
  end else begin
      form5.ComboBox1.Visible:=false;
  end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:32 Uhr.

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