zanona Posted September 15, 2017 Share Posted September 15, 2017 Is there any way to right-align the given cell in the unistringgrid as per example below? Do I just need cell "x" to stay right? Thansks Zanona Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 16, 2017 Share Posted September 16, 2017 Hi, By what condition? Best regards, Quote Link to comment Share on other sites More sharing options...
zanona Posted September 16, 2017 Author Share Posted September 16, 2017 if col = 10rigthtif col = 20 rigth if col = 100 left Quote Link to comment Share on other sites More sharing options...
mhmda Posted September 16, 2017 Share Posted September 16, 2017 col number/value ???? Quote Link to comment Share on other sites More sharing options...
zanona Posted September 16, 2017 Author Share Posted September 16, 2017 It's not like this! Sample if col = 10{ format to right cell content } Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 16, 2017 Share Posted September 16, 2017 Hi, Do you mean the value of the cell ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 16, 2017 Share Posted September 16, 2017 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; Quote Link to comment Share on other sites More sharing options...
Gabriel Posted November 11, 2019 Share Posted November 11, 2019 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 11, 2019 Share Posted November 11, 2019 35 minutes ago, Gabriel said: I will like to know the css apply to a particular cell (it can change during the execution) Hi, Specifically, what style do you want to apply? Quote Link to comment Share on other sites More sharing options...
Gabriel Posted November 11, 2019 Share Posted November 11, 2019 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 11, 2019 Share Posted November 11, 2019 4 minutes ago, Gabriel said: The user can change the "format" of the cell during execution How does a user change the attribute of a cell? I think that at this moment you can note... Quote Link to comment Share on other sites More sharing options...
Gabriel Posted November 11, 2019 Share Posted November 11, 2019 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 11, 2019 Share Posted November 11, 2019 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? Quote Link to comment Share on other sites More sharing options...
Gabriel Posted November 11, 2019 Share Posted November 11, 2019 Sorry, wrong testcase StringGrid Demo.rar Quote Link to comment Share on other sites More sharing options...
webdev Posted June 6, 2022 Share Posted June 6, 2022 Hi. Attribs.Style.Style := 'text-align: right'; Error when implementing: Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 6, 2022 Share Posted June 6, 2022 4 minutes ago, webdev said: Attribs.Style.Style := 'text-align: right'; Error when implementing: 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.