Reputation: 341
I'm using Delphi XE7 for developing Android application. In that I have used TStringGrid component and then I have used
StringGrid.cells[0, 0] := 'Test'
And how can I change the Font colour of that particular cell which I have shown in the code. And also I have this sample code, but I can not change the font colour of the particular cell. Please anybody explain me how to change the font colour of the particular cell value. And I'm using Delphi XE7 and I'm targeting Android mobile.
Thanks..
Upvotes: 0
Views: 6285
Reputation: 1
Works in XE8 as well for the TStringGrid
OnDrawColumnCell
event.
Herewith an example that keeps the color on black but sets the font styling to bold. Tip, add 2 pixels padding for the font, from the left margin.
var Rect : TRectF;
begin
Rect := Bounds;
Rect.Left := Rect.Left + 2;
Canvas.Font.Style := [TFontStyle.fsBold];
Canvas.Fill.Color := TAlphaColorRec.Black;
Canvas.FillText(Rect, (Value.AsString), false, 100, [], TTextAlign.taLeading, TTextAlign.taCenter);
end;
What I missed in the beginning was not setting the DefaultDrawing to false! After I set that, the event was accepting changes to the Canvas.
Upvotes: 0
Reputation: 341
At last, I have found the solution which I required. Please follow the Steps. We can able to change the font color in TStringGrid itself, No need to use TGrid. Please follow the below steps.
First assign this in FormCreate event:
StringGrid1.DefaultDrawing := False;
then write this in StringGrid DrawColumnCell event:
Canvas.fill.Color := TAlphaColorRec.Green;
Canvas.FillText(Bounds, (Value.AsString),
false, 100, [], TTextAlign.taLeading, TTextAlign.taCenter);
Upvotes: 0
Reputation: 4211
In a FireMonkey TStringGrid there are no per cell styling options. You will either need to use a third party grid control or roll something yourself from TGrid.
You can find plenty of material on the latter on my site at http://monkeystyler.com/guide
Upvotes: 1