Jump to content

TstringGrid Cell align


lcolombo

Recommended Posts

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

Link to comment
Share on other sites

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
}

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...