Jump to content


Photo

How to Coloring Font base on value in NextDBGrid 6


  • Please log in to reply
13 replies to this topic

#1 Bagong

Bagong
  • Members
  • 34 posts

Posted 19 May 2019 - 05:12 PM

Hi boki, i am stll waiting the new version.

And now i want to know how to Coloring Font base on value in NextDBGrid 6..

 

in next dbgrid 5, there was OnCellColoring or OnCellFormating.



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 19 May 2019 - 05:20 PM

Hi,

 

You can use next event. This event is located in Column:

 

procedure TForm1.NxTextColumn61StyleText(Sender: TObject; ACol, ARow: Integer;
  var FontColor: TColor; FillColor: TColor; var FontStyle: TFontStyles;
  CellValue: INxBase; CellState: TNxCellPaintingState);
begin
// Set some of var parameters
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 19 May 2019 - 05:21 PM

PS. Also add NxIntf6, NxTypes6 in uses section.


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.

#4 Bagong

Bagong
  • Members
  • 34 posts

Posted 14 March 2021 - 03:51 PM

 

Hi,

 

You can use next event. This event is located in Column:

procedure TForm1.NxTextColumn61StyleText(Sender: TObject; ACol, ARow: Integer;
  var FontColor: TColor; FillColor: TColor; var FontStyle: TFontStyles;
  CellValue: INxBase; CellState: TNxCellPaintingState);
begin
// Set some of var parameters
end;

Boki, could you please explain more with example..

i need coloring rows with content "close"



#5 Bagong

Bagong
  • Members
  • 34 posts

Posted 15 March 2021 - 03:31 AM

i mean, all row will be change color if that column value is defined



#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 15 March 2021 - 12:16 PM

Hello,

 

You can also check ARow parameter and depending on its value do the change. 


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.

#7 Bagong

Bagong
  • Members
  • 34 posts

Posted 20 March 2021 - 10:54 AM

Hello,

 

You can also check ARow parameter and depending on its value do the change. 

Boki,

please correct me in this code..

 

procedure TFLinPM.CoLinStaStyleText(Sender: TObject; ACol, ARow: Integer;
  var FontColor: TColor; FillColor: TColor; var FontStyle: TFontStyles;
  CellValue: INxBase; CellState: TNxCellPaintingState);
begin
 
if ACol = 12 then
  if CellValue.AsString = 'Closed' then
    begin
    GrLin.Columns[1].Font.Color := clGreen;
    end;
 
 
end;


#8 Bagong

Bagong
  • Members
  • 34 posts

Posted 20 March 2021 - 11:51 AM

procedure TFLinPM.CoLinStaStyleText(Sender: TObject; ACol, ARow: Integer;
  var FontColor: TColor; FillColor: TColor; var FontStyle: TFontStyles;
  CellValue: INxBase; CellState: TNxCellPaintingState);
begin
 
  if CellValue.AsString = 'Closed' then
    begin
    GrLin.Cell[ARow,ACol].Color := clGreen;
    GrLin.Cell[ARow,2].Color := clGreen;
    GrLin.Cell[2,ACol].Color := clGreen;
    end;
 
end;
 
 
 
 
i try this, doesnt work too


#9 Bagong

Bagong
  • Members
  • 34 posts

Posted 20 March 2021 - 12:13 PM

a simple thing, please convert this code (ver 5)

 

procedure TForm1.NextGrid1CellFormating(Sender: TObject; ACol, ARow: Integer; var TextColor: TColor; var FontStyle: TFontStyles; CellState: TCellState);

begin

if (ACol = 3) and not(csSelected in CellState) then

begin

TextColor := clRed;

FontStyle := [fsBold];

end;

end;

 

 

to ver 6th.

 

 

my goal is gives possibility to set custom Font TColor or TFontStyle based on ACol and ARow parameters.



#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 20 March 2021 - 04:58 PM

 

Boki,

please correct me in this code..

 

procedure TFLinPM.CoLinStaStyleText(Sender: TObject; ACol, ARow: Integer;
  var FontColor: TColor; FillColor: TColor; var FontStyle: TFontStyles;
  CellValue: INxBase; CellState: TNxCellPaintingState);
begin
 
if ACol = 12 then
  if CellValue.AsString = 'Closed' then
    begin
    GrLin.Columns[1].Font.Color := clGreen; // <--- replace with FontColor := clGreen;
    end;
 
 
end;

 

Hi,

 

You are pretty close to the solution. You just need to set var parameters from this procedure, such as FontColor, FontStyle or FillColor, but not set properties of columns. 


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.

#11 Bagong

Bagong
  • Members
  • 34 posts

Posted 21 March 2021 - 02:16 AM

Hi,

 

You are pretty close to the solution. You just need to set var parameters from this procedure, such as FontColor, FontStyle or FillColor, but not set properties of columns. 

 

could you write the code should be..



#12 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 24 March 2021 - 11:05 AM

Probably something like this:

 

procedure TFLinPM.CoLinStaStyleText(Sender: TObject; ACol, ARow: Integer;
  var FontColor: TColor; FillColor: TColor; var FontStyle: TFontStyles;
  CellValue: INxBase; CellState: TNxCellPaintingState);
begin
 
if ACol = 12 then
  if CellValue.AsString = 'Closed' then
    begin
       FontColor := clGreen;
    end;
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.

#13 Bagong

Bagong
  • Members
  • 34 posts

Posted 25 March 2021 - 03:27 AM

 

Probably something like this:

procedure TFLinPM.CoLinStaStyleText(Sender: TObject; ACol, ARow: Integer;
  var FontColor: TColor; FillColor: TColor; var FontStyle: TFontStyles;
  CellValue: INxBase; CellState: TNxCellPaintingState);
begin
 
if ACol = 12 then
  if CellValue.AsString = 'Closed' then
    begin
       FontColor := clGreen;
    end;
end;

 

 

Hi Boki, 

that code will make green color just for its column.

I need the green color in arow with status "Closed".

I have no problem with version 5, cause there was a cellformating event there.



#14 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 02 April 2021 - 11:57 AM

Hi,

 

This still should work only if value is “Closed”.


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.




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users