Jump to content


Photo

OnCellFormating issue


  • Please log in to reply
3 replies to this topic

#1 Alex

Alex
  • Members
  • 17 posts

Posted 07 May 2017 - 12:13 AM

Hello, i got a problem with the OnCellFormating event. I copied the code from my other project to the new one, and now the event called all the time if there are records in the grid (-> 100% cpu core utilization):
 
  if (ACol = 3) then
  begin
    NextGrid1.Cell[ACol, ARow].TextColor:=clRed;
  end;
this code works fine (0% cpu utilization):
  if (ACol = 3) then
  begin
    beep;
  end;
 
I'm using Delphi Seattle, NG Version 5.9.75. Thank you.

 



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 07 May 2017 - 03:16 AM

Hi,

Hm, Not sure if this is best place for setting TextColor of same cell as there is a parameter (var) with same purpose.

Maybe you can try to use parameter instead of property?
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 Alex

Alex
  • Members
  • 17 posts

Posted 07 May 2017 - 01:58 PM

This is it. In my previous code I set color for 2 columns:

    TextColor := tmpColor;
    NextGrid1.Cell[ACol-2, ARow].TextColor:=tmpColor;

In my current project I paint only 1 column, so I deleted the first line and edited second... Thank you. :)



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 07 May 2017 - 02:40 PM

Great!

Setting property will call repainting of cell once again (event is placed inside OnPaint), and you will enter into recursion.
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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users