Two button columns with different images index 0 and 1.
When using the same buttontext ‘x’, the images are also the same in the two grid columns???
procedure TFormTestFNCGrid.FormShow(Sender: TObject);
begin
GridA.AddButtonColumn(0,'x');
GridA.AddButtonColumn(1,'x');
end;
procedure TFormTestFNCGrid.GridAGetCellProperties(Sender: TObject; ACell: TTMSFNCDataGridCell);
begin
if ACell.IsButtonCell then
begin
ACell.AsButtonCell.Button.Images:=VirtualImageList;
if ACell.Column=0
then ACell.AsButtonCell.Button.ImageIndex:=0;
if ACell.Column=1
then ACell.AsButtonCell.Button.ImageIndex:=1;
Hi, this is due to cell control caching for performance and speed enabled by default. We are looking into a way of specifying additional control properties to be check when creating image caches. For now, you can workaround it by defining your own cell class
type
TGlowButtonCell = class(TTMSFNCDataGridButtonCell)
public
function SupportsRealControl: Boolean; override;
end;
...
{ TGlowButtonCell }
function TGlowButtonCell.SupportsRealControl: Boolean;
begin
Result := True;
end;
procedure TForm13.TMSFNCDataGrid1GetCellClass(Sender: TObject; AColumn,
ARow: Integer; var ACellClass: TTMSFNCDataGridCellClass);
begin
ACellClass := TGlowButtonCell;
end;
I completely understand that this installs more complexity, but the choice was made for performance reasons. We are currently working on events to handle this, where you can switch to real controls via a single line of code. Real controls on the other hand can still be installed via Grid.Controls[Col, Row] although this is a manual process.
I’m providing a workaround in the meantime until the next version is available, where you will be able to do this:
procedure TForm1.TMSFNCDataGrid1GetCellSupportsRealControl(Sender: TObject;
AColumn, ARow: Integer; AControl: TControl;
var ASupportsRealControl: Boolean);
begin
ASupportsRealControl := True;
end;
Enable real controls grid-wide or control which properties are used for the caching mechanism
procedure TForm1.TMSFNCDataGrid1GetCellControlExtraProperties(Sender: TObject;
AColumn, ARow: Integer; AControl: TControl;
var AExtraProperties: TArray<System.string>);
begin
AExtraProperties := ['ImageIndex'];
end;
By the way: Why are you putting so many grid definition properties into events? From a maintenance point of view it would be better to have a clear seperation between definition, writing/reading and user events…
About user events: There are important events missing (Key press in edit, click in combobox)
It always has been a way of providing maximum flexibility. At some point we see what’s possible to define grid & column properties without making it cluttered.