Realign windows grid4/8/2023 Maximizing, Restoring, and Minimizing Windows Drop the window on the edge of the screen and it will be automatically resized to take up the appropriate side of the screen. You’ll see a preview of the shape the window will become. You can also click a window title bar, hold down the mouse button, and drag the window’s title bar to the left or right edge of the screen. The current window will be resized and placed at the left or right side of the screen. To use Aero Snap, hold the Windows key and press the left or right arrow keys. Procedure TGridColumnHelper.SetEditTextAlign(aValue: TTextAlign) Īfter the binding has filled the grid, you can call the helpers: (TTextAlign.The Snap feature makes a window take up half of your screen, making it easy to arrange two windows side by side without manually resizing and moving them around. Procedure TGridColumnHelper.SetEditMaxLength(aValue: Integer) Procedure SetEditTextAlign(aValue: TTextAlign) Procedure SetEditMaxLength(aValue: Integer) TGridColumnHelper = class helper for TColumn Not too elegant but simple and works: unit GridColumnHelper įmx.Types, Fmx.Controls, Fmx.Grid, Fmx.Edit If you use livebindings when you have less chance to customize the column class which is being created, but you can create helpers for Column which sets some attributes of individual cell controls. M圜olumn.HorizontalAlign:=TTextAlign.taCenter Layout.HorizontalAlign := HorizontalAlign //add this line *****įinally you can set the new property in your Project. Procedure TColumn.DefaultDrawCell(const Canvas: TCanvas const Bounds: TRectF const Row: Integer Ĭonst Value: TValue const State: TGridDrawStates) įDrawable.DrawCell(Canvas, Bounds, Row, Value, State) Property HorizontalAlign: TTextAlign read FHorizontalAlign write FHorizontalAlign //add this line ******* TColumn = class(TStyledControl)įHorizontalAlign:TTextAlign //Add this Line ********* Instead of modifiying original FMX.Grid pas, I recommend copying original FMX.Grid pas to your Project directory, including in your Project (add to Project) and adding/modifiying following lines. TTextCell(Result).TextAlign := taTrailing įinally, your GetValue event handler needs do nothing more than return the value: procedure TForm1.Grid1GetValue(Sender: TObject const Col, Row: Integer Īdding/modifying 3 lines in solves this problem. function TStringColNum.CreateCellControl: TStyledControl You don't need the Create method for your column (it's doing nothing), so delete it (unless you need it for something else) and amend your CreateCellControl. You're actually creating an instance of your column which is your main problem. Your column needs to create your cells in the CreateCellControl method. No need to mess with styles (unless you really want to). Being a TEdit means changing the alignment is really easy: just change the TextAlign property. The default for a text cell is TTextCell, which is simply a TEdit. T := (Cell.FindStyleResource('text') as TText) Īll of which reminds me that I still haven't written my blog post about this.Īnyway, a grid cell can be any descendant of TStyledControl (basically any control). Procedure TForm1.Grid1GetValue(Sender: TObject const Col, Row: Integer Ĭell := (Row) Grid1.AddObject(TStringColNum.Create(Self)) // Right Aligned column? Grid1.AddObject(TStringColumn.Create(Self)) Procedure TForm1.Button1Click(Sender: TObject) Procedure Grid1GetValue(Sender: TObject const Col, Row: Integer įunction CreateCellControl: TStyledControl override Ĭonstructor Create(AOwner: TComponent) override Ĭonstructor TStringColNum.Create(AOwner: TComponent) įunction TStringColNum.CreateCellControl: TStyledControl System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,įMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Objects, FMX.Grid, Any help appreciated as this one is a basic requirement of any grid work. The code below shows that it is a simple TGrid, with 2 cols, 1 the standard StringColumn and 1 my new StringColNum (wuth right alignment applied). The only way to get the grid back in line is do a column resize for example - which then redraws correctly? It could be a bug/feature of the Grid (or the way I am doing it). the new TColumn type column does not appear to refresh correctly using the method/code below. The problem is however that although at first it looks OK, if you scroll the bar/mouse wheel etc. The values are provided by the OnGetValue function to the Grid control. From other users postings, I have managed to create a new TColumn type, apply a style to this (text as HorzAlign=taTrailing) and in theory - thought that this would be solution. I am using the FireMonkey Grid control but have an on-going issue in trying to right align a column.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |