Delphi-PRAXiS

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/)
-   -   Delphi StringGrid --> FixedRows nicht neu zeichnen (OnDrawCell?) (https://www.delphipraxis.net/46807-stringgrid-fixedrows-nicht-neu-zeichnen-ondrawcell.html)

ereetzer 31. Mai 2005 21:20


StringGrid --> FixedRows nicht neu zeichnen (OnDrawCell?)
 
Hallo,

Ausgangssituation ist folgende:

per Abfrage im OnMouseUp-Ereignis prüfe ich mit Hilfe von MouseToCell die angeklickte Spalte im StringGrid.

Diese wird dann entsprechend ab- bzw. aufsteigend sortiert.

Nun will ich das ganze aber auch noch visualisieren indem ich eine Art Pfeil in der jeweiligen Zelle darstelle.

Ich schaffe es auch, daß das Bild angezeigt wird. Allerdings nur ganz kurz, da nämlich sofort alles wieder duch das OnDrawCell alles überschreiben wird. Kann ich das irgendwie verhindern?

Ich hoffe, ich hab das Problem gut genug beschrieben :lol:

ereetzer

Hansa 31. Mai 2005 21:31

Re: StringGrid --> FixedRows nicht neu zeichnen (OnDrawCe
 
Du mußt das ACol, ARow überprüfen ! Vermute außerdem, daß das irgendwie falsch deklariert ist. 8)

ereetzer 31. Mai 2005 21:33

Re: StringGrid --> FixedRows nicht neu zeichnen (OnDrawCe
 
hmm, hab aber ne Abfrage drin:

Delphi-Quellcode:
if ARow > 0 then...
das klappt aber trotzdem nicht.

edit:

hier mal nen bißchen Code aus OnMouseUp:

Delphi-Quellcode:
procedure TForm4.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  iColumn, iRow: integer;
  Bild: TBitmap;
  Rect: TRect;
begin
  sort := not sort;
  StringGrid1.MouseToCell(X, Y, iColumn, iRow);
  if (iRow = 0) and (iColumn <> -1) then
  begin
    SortStringGrid(StringGrid1, iColumn, sort);
  end;

  if iRow = 0 then
  begin
    Bild := TBitmap.Create;
    Bild.LoadFromFile('C:\Blau.bmp'); // TEST
    Rect := StringGrid1.CellRect(iColumn, iRow);
    StringGrid1.Canvas.StretchDraw(Rect, Bild);
  end;

Hansa 31. Mai 2005 21:40

Re: StringGrid --> FixedRows nicht neu zeichnen (OnDrawCe
 
probiere mal >1 aus oder > FixedRows. Verwechsle das auch immer.

punker76 1. Jun 2005 07:26

Re: StringGrid --> FixedRows nicht neu zeichnen (OnDrawCe
 
Zitat:

Zitat von ereetzer
hmm, hab aber ne Abfrage drin:

Delphi-Quellcode:
if ARow > 0 then...
das klappt aber trotzdem nicht.

edit:

hier mal nen bißchen Code aus OnMouseUp:

Delphi-Quellcode:
procedure TForm4.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  iColumn, iRow: integer;
  Bild: TBitmap;
  Rect: TRect;
begin
  sort := not sort;
  StringGrid1.MouseToCell(X, Y, iColumn, iRow);
  if (iRow = 0) and (iColumn <> -1) then
  begin
    SortStringGrid(StringGrid1, iColumn, sort);
  end;

  if iRow = 0 then
  begin
    Bild := TBitmap.Create;
    Bild.LoadFromFile('C:\Blau.bmp'); // TEST
    Rect := StringGrid1.CellRect(iColumn, iRow);
    StringGrid1.Canvas.StretchDraw(Rect, Bild);
  end;

du solltest das bild im constructor laden und im OnDrawCell (der name sagts ja schon) in die jeweilige zelle in den fixedrows zeichnen!


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:57 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