TMSFMXTableView Right Rectangle Customization

in XE7 iOS app I have followed the instructions fo adding a TEdit to the Right Rectangle:

First, add a TEdit control to the right rectangle element in the StyleBook. Set the TEdit control stylename to 'item_edit'.

But when saving and reopening the project I get the error class TStyledEdit not found!

Any help greatly appreciated.

It seems to be an issue at designtime which is unable to create a TStyledEdit. This is because the TStyledEdit is created at runtime depending on the kind of TEdit you have configured. In XE7 you can select to create a TEdit with styling options or a TEdit native to the platform.


TStyledEdit is related to styles and cannot be created directly. To overcome this issue, you will need to create a TEdit at runtime by using the following code:

procedure TForm91.TMSFMXTableView1ItemCustomize(Sender: TObject;
  AItem: TTMSFMXTableViewItem; AItemShape: TTMSFMXTableViewItemShape;
  AItemControlShape: TControl);
var
  e: TEdit;
  r: TRectangle;
begin
  r := AItemShape.ShapeRightRectangle;
  if r.ControlsCount = 0 then
  begin
    e := TEdit.Create(r);
    e.Parent := r;
  end;
end;

Kind Regards, 
Pieter

Thanks. So does this mean that there is no need to add it to the stylebook as per your documentation? Do you have a complete sample of this?

There seems to be an issue in XE7 when adding TEdit to the stylebook. Adding it programmatically will give you more flexibility. There is no complete sample for this, but it also depends on the usage. What exactly do you want to do with TEdit in the right-rectangle?


Please note that some items will be re-created so TEdit text should be persisted in the item data or a separate collection/list.

Kind Regards, 
Pieter

I actually don't want to use a TEdit I was just trying to get the example given in your documentation before moving on. I actually want to use a TComboBox or perhaps even you own TTMSFMXSpinner.

You can use the same approach.


Kind Regards, 
Pieter

Thanks. It works very well with a TSpinBox.

I tried this with a TLabel. Don't need to do databinding as I want to set the values in code. However the TLabel shows up in the ShapeRightRectangle.Controls[0] list, but is not visible. I've set the rectangle background to aqua, the font of the label to size 20 and font color of navy. I've set the label parent to the rectangle and the position of x=1, y=1. Yet when I run the app the label is not displayed!


Is this a problem with the TLabel? Is the label not a valid control for this?

Please provide direction.

Thanks.

A Label should be available as well, but it is cloned, so it could be possible that the text you have set is empty after cloning. Can you try to set a text in the OnItemCustomize event?

I've been doing this all along. See anything I'm missing? 

I'd like to set 4 labels in there. Two are used as labels, 2 are used as colored data fields adjacent to the other labels.

Thanks.

procedure TfrmTrack.TrackViewItemCustomize(Sender: TObject; AItem: TTMSFMXTableViewItem;
  AItemShape: TTMSFMXTableViewItemShape; AItemControlShape: TControl);
var
  panel: TRectangle;
  lbl: TLabel;
  edt: TEdit;
begin
  panel := AItem.ShapeRightRectangle;
  if Assigned(panel) then
  begin
    panel.fill.Color := TAlphaColorRec.Aqua;
    if panel.ControlsCount = 0 then
      ;
    edt := TEdit.Create(panel);
    edt.Parent := panel;
    edt.Position.Y := 1;
    edt.Height := 18;
    edt.Position.X := panel.Size.Height - edt.Size.Height - 1;
    edt.Text := 'Rad:';
//    lbl := TLabel(panel.FindStyleResource('labelstyle'));
    lbl := TLabel.Create(panel);
     if Assigned(lbl) then
    begin
      lbl.Parent := panel;
      lbl.Text := 'Lab';
      lbl.Position.X := 1;
      lbl.Position.Y := 1;
      lbl.Size.Width := 25;
      lbl.TextSettings.Font.Size := 20;
      lbl.TextSettings.Font.Style := [TFontStyle.fsBold];
      lbl.TextSettings.FontColor := TAlphaColorRec.Navy;
      lbl.BringToFront;
    end;
  end;
end;

One thing I did in troubleshooting is to change the TLabel to a TEdit, using the same settings. I noticed that when I run the app and mouseover the right rectangle, when I'm in the vicinity of the TEdit the cursor changes to the edit box cursor. When I move off of the TEdit, the cursor changes back to the default arrow cursor. So it's definitely putting the edit box there.


ControlsCount = 1
TextSettings.FontColor = DarkBlue or Navy
Parent = ShapeRightRectangle
Visible = True
Canvas.Fill.Color = Red
TextSettings.Font.Style = Bold
TextSettings.Font.Size = 20
Position.X = 1
Position.Y = 1
Text = Lab

I've tried calling control.BringToFront, Repaint etc. It's there, but it's not rendering properly. If I set the Rectangle Fill color to white, the rectangle appears as white, but nothing else is visible.

Is this some sort of rendering issue?

using D10 Seattle Enterprise