lcolombo Posted October 22, 2021 Share Posted October 22, 2021 Hi, I need to right align cells that have a numeric value or a date. I tried the following but it is very slow: procedure TMyForm.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer; var Value: string; Attribs: TUniCellAttribs); begin if (isNumeric(Value) or isDate(Value)) then begin Attribs.Style.Style := 'text-align: right;'; end; if ARow = 0 then Attribs.Style.Style := 'text-align: center'; end; Is there an alternative that uses clients events? Regards Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2021 Share Posted October 22, 2021 Hello, 2 hours ago, lcolombo said: I tried the following but it is very slow: Do you have so many records? Quote Link to comment Share on other sites More sharing options...
lcolombo Posted October 22, 2021 Author Share Posted October 22, 2021 Sherzod, The grid has 40 columns and 1100 rows. With the ondrawcell event it takes several minutes to display the grid. Without the ondrawcell event, the grid is displayed immediately. Regards, Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2021 Share Posted October 22, 2021 Okay. You need to use customCSS then. Quote Link to comment Share on other sites More sharing options...
lcolombo Posted October 22, 2021 Author Share Posted October 22, 2021 Sherzod, Can I set a css class for some cells? something like that: StringGrid1.Cells[Col, Row].style := 'mycls'; Regards Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2021 Share Posted October 22, 2021 function beforereconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { } ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 22, 2021 Share Posted October 22, 2021 31 minutes ago, lcolombo said: Can I set a css class for some cells? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 23, 2021 Share Posted October 23, 2021 15 hours ago, lcolombo said: Can I set a css class for some cells? something like that: StringGrid1.Cells[Col, Row].style := 'mycls'; For a simple case, like so for example: function beforereconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { columns[1].align = 'right'; //center, left } Quote Link to comment Share on other sites More sharing options...
lcolombo Posted October 26, 2021 Author Share Posted October 26, 2021 Sherzod, The problem was in the isnumber function that I used inside the ondrawcell event and not in the ondrawcell event. Thank you very much for the support. 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.