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

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