Print Page | Close Window

Tableview alignment not working

Printed From: TMS Software
Category: FMX Components
Forum Name: FMX mCL
Forum Discription:
URL: http://www.tmssoftware.com/site/forum/forum_posts.asp?TID=3108
Printed Date: 24 Jan 2020 at 8:47pm


Topic: Tableview alignment not working
Posted By: Shelton Brent
Subject: Tableview alignment not working
Date Posted: 21 Oct 2013 at 12:54pm
In the Tableview I cannot get the alignment to work

  with TableView1.Columns.Add do begin
    Header := 'Date';
    ReadOnly := True;
    Alignment := TTextAlign.taCenter;
  end;



Replies:
Posted By: Pieter Scheldeman
Date Posted: 22 Oct 2013 at 2:37am
Hi, 

The Alignment property is used for the column values, not for the column header. You can access the native column with the following code, and set the alignment there:

  TNSTableHeaderCell.Wrap(TMSFMXNativeNSTableView1.Columns[0].GetTableColumn.headerCell).setAlignment(2);

Values for alignment are:

NSLeftTextAlignment      = 0
NSRightTextAlignment     = 1
NSCenterTextAlignment    = 2
NSJustifiedTextAlignment = 3
NSNaturalTextAlignment   = 4

Kind Regards, 
Pieter



Posted By: Shelton Brent
Date Posted: 22 Oct 2013 at 8:44am
Which unit do I need to include to use TNSTableHeaderCell?


Posted By: Pieter Scheldeman
Date Posted: 22 Oct 2013 at 8:48am
The unit iOSApi.UIKit should be the unit which declares the NSTableHeaderCell


Posted By: Shelton Brent
Date Posted: 22 Oct 2013 at 9:17am
This is a Mac app not an iOS app.  Delphi doesn't recognize that unit.


Posted By: Pieter Scheldeman
Date Posted: 23 Oct 2013 at 7:19am
the MacApi.AppKit unit.


Posted By: Shelton Brent
Date Posted: 23 Oct 2013 at 1:34pm
It got this to work in the form create but I had to put it after the TableView1.EndUpdate or the program crashes:
TNSTableHeaderCell.Wrap(TMSFMXNativeNSTableView1.Columns[0].GetTableColumn.headerCell).setAlignment(2);

I also have to put the code in the GetAlignment event.

I cannot get the regular cells to align though.  How should I do that?


Posted By: Pieter Scheldeman
Date Posted: 24 Oct 2013 at 2:33am
Normally this should be done with the Alignment property for each column as shown in your first post.
Are you experiencing difficulties with this?

Kind Regards, 
Pieter


Posted By: Brent Shelton
Date Posted: 04 Aug 2016 at 10:44pm
I figured I'd use this old post.  How can I set the alignment of a checkbox in a cell?  The checkbox shows up when I use Values.Add.BooleanValue := True;

Thanks!
Brent


Posted By: Pieter Scheldeman
Date Posted: 05 Aug 2016 at 9:04am
Hi, 

We have investigated this here and have applied a content alignment property at column level and the appriopriate event for further customization. The next version will allow you to set checkboxes centered with the columns CellContentAlignment property.



Print Page | Close Window