Jump to content


Photo

OnDrawContent problem


  • Please log in to reply
2 replies to this topic

#1 philwx

philwx
  • Members
  • 2 posts

Posted 19 December 2024 - 02:28 PM

I've got a grid with a date column that I'm trying to override the display of so that it shows custom text for certain dates/times instead of the actual date/time.  I've set the column to doBackground and doCustom only, not doContent, and then using the following onDrawContent routine (which obviously doesn't do what I want, just trying to text), and I get blank cells - background as it should be, but nothing painting or writing. 

 

I've tried following the example codes in the demos and on the forum, and it looks like that's all I should need, but is there a step I'm missing? 

 

Thanks for any assistance!

procedure TfrmEditor.drawContent(Sender: TObject; ACol, ARow: Integer; CellRect: TRect; State: TNxCellPaintingState);
   begin
   grid.canvas.font.Color := clYellow;
   grid.Canvas.Pen.Color := clYellow;
   grid.canvas.Ellipse( cellRect.Left, cellRect.Top, cellRect.Right, cellRect.Bottom );
   grid.Canvas.TextRect( cellRect, 0, 0, 'Text' );
   end;


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,230 posts
  • Gender:Male

Posted 20 December 2024 - 02:13 PM

Hi,

 

It seems that the Ellipse have Brush.Color missing and Text was placed on the top/left corner relative to the grid, not a cell. I have fixed this code and this is the example:

 

procedure TForm3.NxDateColumn61DrawContent(Sender: TObject; ACol, ARow: Integer;
  CellRect: TRect; State: TNxCellPaintingState);
begin
   NextGrid61.canvas.font.Color := clYellow;
   NextGrid61.Canvas.Pen.Color := clYellow;
   NextGrid61.Canvas.Brush.Color := clRed;
   NextGrid61.canvas.Ellipse( cellRect.Left + 5, cellRect.Top + 5, cellRect.Right - 10, cellRect.Bottom - 10 );
   NextGrid61.Canvas.TextRect( cellRect, cellRect.Left, CellRect.Top, 'Text' );
end;

boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 philwx

philwx
  • Members
  • 2 posts

Posted 22 December 2024 - 07:58 PM

Thank you!!






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users