Create TableView at runtime

I've subclassed a TMSFMXTableViewEx:



type
  TMyTableView = class(TTMSFMXTableViewEx)
  public
    constructor Create(AOwner: TComponent); reintroduce;
  end;


constructor TMyTableView.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Parent := TTMSFMXBaseControl(AOwner);
  StyleName := 'TMSFMXTableViewStyle'; //TForm(AOwner).StyleBook.StyleName;
  Align := TAlignLayout.Client;
  DisableFocusEffect := False;
  TabOrder := 1;
  CanFocus := True;
  AutoFilter := False;
  AutoDeleteItem := False;
  AutoLoadBuffer := False;
  AutoLookup := False;
  AutoToggleDetail := True;
  ScrollIndicator := siPermanent;
  LookupBar := False;
  ShowFilterOnSwipe := False;
  MarkText := 'Mark';
  MoveText := 'Move';
  ArchiveText := 'Archive';
  ItemOptions := [ioCenterRectangle, ioRightRectangle, ioDetailRectangle, ioCaptionElement, ioDescriptionElement];
  FMaxLabRadWidth := 0;
//  OnItemCustomize := TrackViewItemCustomize;
end;

When I create the host form:

procedure TfrmTrack.FormCreate(Sender: TObject);
begin
  FMyTableView := TMyTableView.Create(Self);
end;

...nothing happens! I just get a blank white form! The form has a tstylebook with only a default style.

What needs to be done to initialize/display the tableview?

Please read the following tip on how to subclass:

http://www.tmssoftware.com/site/tmsfmxpack.asp?s=faq&show=652

The tip is applied to TTMSFMXGrid but can be applied to any styleable control, simply replace grid with tableview

  1. Home
  2.  
  3. ERROR 404

Sorry, the page you are looking for does not exist.

You can perform a website search or return to the home page.
This link works here:
http://www.tmssoftware.com/site/tmsfmxpack.asp?s=faq&show=652 

The link works but the method when implemented exactly as displayed except for the tableview makes no difference. Is some sort of customization required? Again, I'm not customizing anything via styles, just using the default. If I didn't have to use styles at all that would be vastly preferable.



Hi,



This is a requirement for inheriting from styled controls. You always need to return the default style. if you keep experiencing issues using this approach you can contact us directly by email and send us your test project. There is something simple missing that shows a blank TTMSFMXTableView.

Emailed a test project illustrating the problem to support@tmssoftware.com.

When inheriting from TTMSFMXTableView, the code will work correctly. When inheriting from TTMSFMXTableViewEx, there is an additional level, so the style needs to be retrieved from the root TTMSFMXTableView class so the code need to change to:


  1. function TMyTableView.GetClassStyleName: String;  
  2. begin  
  3.   Result := ClassParent.ClassParent.ClassName + ''style'';  
  4.   Delete(Result, 11);  
  5. end;  

Pieter Scheldeman2016-09-05 09:08:28

Thank you for clearing that up. That was the issue!


Thanks again.