Jump to content

right-align unistringgrid


zanona

Recommended Posts

Do you mean the value of the cell ?

 

If yes, try like this,

 

UniStringGrid1 -> OnDrawCell:

procedure TMainForm.UniStringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  var Value: string; Attribs: TUniCellAttribs);
var
  S : string;
  Val : Integer;
begin
  S:=TUniStringGrid(Sender).Cells[ACol, ARow];
  Val:=StrToIntDef(S, -1);
  case val of
    0..1000 :
    begin
      //Attribs.Font.Color:=clNavy;
      Attribs.Style.Style := 'text-align: right; color: navy'
    end;

    1001..20000 :
    begin
      //Attribs.Font.Color:=clRed;
      //Attribs.Font.Style:=[fsBold];
      Attribs.Style.Style := 'text-align: left; color: red; font-weight: bold'
    end;

  end;
end;
Link to comment
Share on other sites

  • 2 years later...
On 9/16/2017 at 10:03 AM, Sherzod said:

 

If yes, try like this,

 

UniStringGrid1 -> OnDrawCell:


procedure TMainForm.UniStringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  var Value: string; Attribs: TUniCellAttribs);
var
  S : string;
  Val : Integer;
begin
  S:=TUniStringGrid(Sender).Cells[ACol, ARow];
  Val:=StrToIntDef(S, -1);
  case val of
    0..1000 :
    begin
      //Attribs.Font.Color:=clNavy;
      Attribs.Style.Style := 'text-align: right; color: navy'
    end;

    1001..20000 :
    begin
      //Attribs.Font.Color:=clRed;
      //Attribs.Font.Style:=[fsBold];
      Attribs.Style.Style := 'text-align: left; color: red; font-weight: bold'
    end;

  end;
end;

Hi, 

 

I know this is an old topic, but, it is possible to access TuniCellAttribs for a UniStringGrid not using the OnDrawCell event?

I will like to know the css apply to a particular cell (it can change during the execution)

 

Regards

Link to comment
Share on other sites

Hi Sherzod, 

 

Sorry but I misspelled. I will like to know the css applied to a particular cell. The user can change the "format" of the cell during execution, and at the moment of saving I will like to know the current style.

Basically I need to access the Attrib attribute of every cell, but not using the OnDrawCell event

 

Regards

Link to comment
Share on other sites

Hi Sherzod, 

I Attach a small testcase...if you click on the first button (UniButton1) with a cell selected (column january) it would change the css of that cell adding (or subtracting) indentation. What i want is get the final indentation of all cells when i click the second button (getInfo).

can you help me?

Regards

UniStringGrid.rar

Link to comment
Share on other sites

9 minutes ago, Gabriel said:

I Attach a small testcase...if you click on the first button (UniButton1) with a cell selected (column january) it would change the css of that cell adding (or subtracting) indentation. What i want is get the final indentation of all cells when i click the second button (getInfo).

can you help me?

Sorry, your test case is not clear to me.

Can you please check it?

Link to comment
Share on other sites

  • 2 years later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...