![]() |
ExpressSpreadSheet mit Hintergrundgrafik in Zellen ...
Moin, moin,
ich möchte bei einem DevExpressGrid eine Hintergrundgrafik in Zellen mit negativen Wert einügen. Das Problem habe ich insofern schon mit Lösung vermischt, als dass es mir möglich ist Grafiken in Zellen auf folgende Art einzubinden
Delphi-Quellcode:
Im Grid selbst muß dann der PainterType auf ptCustom gestellt werdenTMyPainter = class(TcxSheetPainter) private procedure GradientRect(const ARect: TRect; IsHorizontal, IsSelected: Boolean); end; procedure TMyPainter.GradientRect(const ARect: TRect; IsHorizontal, IsSelected: Boolean); //Returns the Red, Green and Blue components of the color procedure ColorToRGBValues(AColor: TColor; var AR, AG, AB: Byte); begin AColor := ColorToRGB(AColor); AR := GetRValue(AColor); AG := GetGValue(AColor); AB := GetBValue(AColor); end; var I, dR, dG, dB: Integer; R, G, B, R1, G1, B1: Byte; //rectangle filled previously PrevLine: TRect; //rectangle to fill currently LineRect: TRect; ABrush: HBrush; const Colors: array[Boolean, 0..1] of TColor = ((clWhite, clBtnShadow), (clHighLight, clWhite)); begin //get the Red, Green and Blue components of the starting color //for the gradient ColorToRgbValues(Colors[IsSelected, 0], R1, G1, B1); //get the Red, Green and Blue components of the ending color //for the gradient ColorToRgbValues(Colors[IsSelected, 1], R, G, B); dR := R - R1; dG := G - G1; dB := B - B1; LineRect := ARect; PrevLine := ARect; for I := 0 to 255 do begin with ARect do begin if IsHorizontal then //determine rectangle boundaries for horizontal filling begin LineRect.Top := Top + MulDiv(I, Bottom - Top, $100); LineRect.Bottom := Top + MulDiv(I + 1, Bottom - Top, $100); end else //determine rectangle boundaries for vertical filling begin LineRect.Left := Left + MulDiv(I, Right - Left, $100); LineRect.Right := Left + MulDiv(I + 1, Right - Left, $100); end; //step over if the same rectangle was filled before if EqualRect(PrevLine, LineRect) then Continue; //define colors to fill R := R1 + MulDiv(I, dR, $FF); G := G1 + MulDiv(I, dG, $FF); B := B1 + MulDiv(I, dB, $FF); //create a brush to fill ABrush := CreateSolidBrush(RGB(R, G, B)); try FillRect(Canvas.Canvas.Handle, LineRect, ABrush); finally DeleteObject(ABrush); end; end; end; end;
Delphi-Quellcode:
ImCustomPaint-Ereignis wird dann mit PainterClass := TMyPainter RMypainter eingebunden.
cxSpreadSheetBook1.PainterType := ptCustom;
Mit ist aber nicht klar, wie ich da eine Abfrage auf Negativwerte in der aktuell zu zeichnenden Zelle hinbekomme. Letzlich sollen die Negativwerte Hervorgehoben werden. Viele Grüße // Martin |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:19 Uhr. |
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-2025 by Thomas Breitkreuz