Jump to content

uniStringGrid or DBGrid


1938

Recommended Posts

4 minutes ago, 1938 said:

How to set the color of a column based on a cell row,column string content?

Hello,

You can use OnDrawCell event, for example:

procedure TMainForm.UniStringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  var Value: string; Attribs: TUniCellAttribs);
begin
  if ACol = 2 then
  begin
    Attribs.Font.Color := clGreen
  end;

end;
\FMSoft\Framework\uniGUI\Demos\Desktop\GridCellStyle

 

Link to comment
Share on other sites

Is there any way to do the entire column?  If an item in row 2 for example is a value, I want the entire column to be a color?

 

Use case:  If column 4 row 2 is "Sunday" I want the entire column 4 background color to be green.

 

-Scott

Link to comment
Share on other sites

So,
On a blank form I drop a uniStringGrid.
Add 3 columns.
set row count to 4.
set Using the object inspector for column[2] I set the color to green.
No effect.

I can determine the columns  that will have the different background colors ahead of time with some extra work, but even if I do, the column  color has no effect.  Am I doing something wrong?  Shouldn't I be able to set both column color and row color?  

-Scott

 

 

Link to comment
Share on other sites

After looking at using DBGrid, the column color works but does not extend to the fixed column cell at the top.  But I lose the ability to specify fixed rows and fixed columns.  I need 2 title lines at the to.  Plus still no way to manage cell outline colors.  

These grids definitely need some attention.  I could patch some of this but even with the source,  I can't build due to select missing .pas files. For example, cell color being forced to clWhite by default in StringGrid which overrides the column color method of the component.  :-(

-Scott

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...