1938 Posted April 27, 2020 Share Posted April 27, 2020 How to set the color of a column based on a cell row,column string content? uniStringGrid.Columns[i].Color:= clGreen; has now effect -Scott Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 27, 2020 Share Posted April 27, 2020 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 Quote Link to comment Share on other sites More sharing options...
1938 Posted April 27, 2020 Author Share Posted April 27, 2020 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 27, 2020 Share Posted April 27, 2020 14 minutes ago, 1938 said: 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? Hmm, I think, under such a condition, this event will not work. Quote Link to comment Share on other sites More sharing options...
1938 Posted April 27, 2020 Author Share Posted April 27, 2020 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 27, 2020 Share Posted April 27, 2020 Maybe better to use UniDBGrid? Quote Link to comment Share on other sites More sharing options...
1938 Posted April 27, 2020 Author Share Posted April 27, 2020 I think that at some point I may end up using a dbgrid. Here is what I'm after. I don't seem to be able to figure out a way to do it via uniGUI. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 27, 2020 Share Posted April 27, 2020 I will analyze. Quote Link to comment Share on other sites More sharing options...
1938 Posted April 27, 2020 Author Share Posted April 27, 2020 Thank you. If column color worked, it would be no problem. -Scott Quote Link to comment Share on other sites More sharing options...
1938 Posted April 29, 2020 Author Share Posted April 29, 2020 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.