Jump to content

Display data in a UniDbGrid with a different color


nickosl50

Recommended Posts

I would like to ask how we can display data in a UniDbGrid with a different font color depending on the value of data.

e.g We have a grid that displays transactions of a customer and we want to to display the rows that have  negative amount values  in red color.

 

 

Thank you very much

Nick

Link to comment
Share on other sites

Hi,

 

You can see our demo examples

 

Are you still using the trial edition?

I looked at mdemo but I could not find an example for this issue. I only saw an example for custom cell color.

 

Yes I am still using trial edition  because I have a look at Unigui part-time . I want to check out some things and most probably will move to full edition .

 

Thank you

Link to comment
Share on other sites

UniDBGrid1 -> OnDrawColumnCell

 

Attribs.Color  -  row (cell) BackgroundColor

Attribs.Font.Color  -  font Color

procedure TMainForm.UniDBGrid1DrawColumnCell(Sender: TObject; ACol,
  ARow: Integer; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);
begin
  if UniDBGrid1.DataSource.DataSet.FieldByName('progress').AsInteger=100 then //for rows
  begin
    Attribs.Font.Style:=[fsbold];
    Attribs.Font.Color:=clWhite; //font color
    Attribs.Color:=clGreen; //background color
  end;
end;

http://forums.unigui.com/index.php?/topic/5851-how-to-change-the-row-font-color-unidbgrid/

...

...

Link to comment
Share on other sites

  • 1 year later...

I do the testcase with the GridCellStyle demo project.

procedure TMainForm.UniDBGrid1DrawColumnCell(Sender: TObject; ACol,
  ARow: Integer; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);
begin
  if ACol = 1 then begin
    //Attribs.Style.Cls:= 'myShadowStyle'; // style is defined in file "files/mycss.css"
    //Attribs.Style.Style := 'border: 5px solid green; font: red'   // define a style directly
    Attribs.Font.Color:=clYellow;
    Attribs.Font.Style:=[fsItalic];
    Attribs.Color:=clRed;
    Attribs.Style.Padding := '5px';
  end else if ACol = 2 then
    Attribs.Style.Padding := '0px';    // force image to fit in the cell
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...