Adding fields to RecordViewPanel at runtime
I would like to add fields a RunTime to the RecordViewpPanel. Unfortunately i can´t find a way to do that.
I would also like to clear all existing Items from the recordviewpanel.
Until now i have this:
var
lRecordView: TwwRecordViewPanel;
lColumn: TwwRecordViewItem;
lFieldProperties: TwwFieldProperties;
lMemTable: TFDMemTable;
I: Integer;
begin
...
lRecordView.SelectedFields.BeginUpdate;
for I := 0 to lMemTable.FieldCount - 1 do
begin
lColumn := TwwRecordViewItem.Create(lRecordView);
lColumn.RecordView := lRecordView;
lColumn.FieldName := lMemTable.Fields[I].FieldName;
lColumn.Text := lMemTable.Fields[I].FieldName;
lColumn.ControlType := TwwDisplayControlType.gdctAsDefault;
lColumn.ItemType := TwwRecordViewItemType.Bound;
lRecordView.SelectedFields.Add(lColumn);
end;
lRecordView.SelectedFields.EndUpdate;
...
end;
Unfortunately that doesn´t work.
-
This seems to work for me.
var item: TwwRecordViewItem;
begin
wwrecordviewpanel1.SelectedFields.Clear;
item:= TwwRecordViewItem.Create(self);
item.FieldName:= 'Customer No';
item.Title:= 'Customer No';
item.Width:= 80;
wwrecordviewpanel1.SelectedFields.Add(item);item:= TwwRecordViewItem.Create(self);
item.FieldName:= 'First Name';
item.Title:= 'First Name';
item.Width:= 80;
wwrecordviewpanel1.SelectedFields.Add(item);wwrecordviewpanel1.RecreateControls;
-
OK, thank you.
With this approach i have another problem only on iOS.
I get an Access Violation when the underlying DataSet is changed.
i tried clearing the fields and setting the BindSource to nil before changing the DataSet but that doesn´t work either.
When i set the Bindingsenabled to false before changing the Datasource, i get an AccesViolation when setting it to true again.
-
We will need a simple project that reproduces the problem. This will help us find the cause of the problem. You can email it to support@woll2woll.com
Please sign in to leave a comment.
Comments
8 comments