I have two FixedRight Columns in a Grid. Each of them have an Image for assigned.
I've assigned an on OnFixedCellClick event to the Grid and....
The las (most right column fires it, but the second column, the most left of the Right Fixed Columns, don't fires this event handler).
You can see it here : https://vine.co/v/i0XeF5D1OBh
I include here the code, modified, respect the original demo: (I can send you the complete code, if you want).
private
{ Added Methods }
procedure SetImages;
procedure ExcludeCurrent;
function SwitchChecked:Boolean;
public
{ Public declarations }
end;
var
Form719: TForm719;
implementation
{$R *.fmx}
const CHECKED = 11;
DELETE = 12;
procedure TForm719.FormCreate(Sender: TObject);
begin
TMSFMXGrid1.BeginUpdate;
TMSFMXGrid1.Options.Bands.Enabled := True;
TMSFMXGrid1.SelectionMode := smSingleRow;
TMSFMXGrid1.DefaultRowHeight := 35;
TMSFMXGrid1.DefaultColumnWidth := 75;
ClientDataSet1.LoadFromFile('....\cars.xml');
BindSourceDB1.DataSet := ClientDataSet1;
TMSFMXGrid1.EndUpdate;
{--- Added code for initialize Data on CHECKED and DELETE Fields ---}
ClientDataSet1.First;
while not ClientDataSet1.EOF do begin
ClientDataSet1.Edit;
try
ClientDataSet1CHECKED.AsString := 'N';
ClientDataSet1DELETE.AsString := 'N';
finally
ClientDataSet1.Post;
end;
ClientDataSet1.Next;
end;
SetImages;
{-------------------------------------------------------------------}
TMSFMXGrid1.CellComboBox.Items.Add('4');
TMSFMXGrid1.CellComboBox.Items.Add('6');
TMSFMXGrid1.CellComboBox.Items.Add('8');
TMSFMXGrid1.CellComboBox.Items.Add('12');
end;
procedure TForm719.TMSFMXGrid1GetCellEditorType(Sender: TObject; ACol,
ARow: Integer; var CellEditorType: TTMSFMXGridEditorType);
begin
if ACol = 6 then CellEditorType := etComboBox
end;
procedure TForm719.TMSFMXGrid1GetCellProperties(Sender: TObject; ACol, ARow: Integer; Cell: TFmxObject);
begin
if Cell is TTMSFMXBitmapGridCell then begin
(Cell as TTMSFMXBitmapGridCell).Bitmap.Align := TAlignLayout.Client;
(Cell as TTMSFMXBitmapGridCell).Bitmap.HitTest := False;
end;
end;
procedure TForm719.TMSFMXGrid1GetCellReadOnly(Sender: TObject; ACol,
ARow: Integer; var AReadOnly: Boolean);
begin
AReadOnly := (ACol = 1) or (ACol = 10);
end;
procedure TForm719.SetImages;
var i :Integer;
begin
BeginUpdate;
try
{--- Apply Bitmap to each cell ---}
for i := 1 to TMSFMXGrid1.RowCount -1 do begin
TMSFMXGrid1.AddBitmap(DELETE , i, 'BitmapDELETE' );
TMSFMXGrid1.AddBitmap(CHECKED, i, 'BitmapUNCHECKED');
end;
finally
EndUpdate;
end;
end;
procedure TForm719.ExcludeCurrent;
begin
ClientDataSet1.Delete;
end;
function TForm719.SwitchChecked:Boolean;
begin
ClientDataSet1.Edit;
try
if ClientDataSet1CHECKED.AsString = 'N' then begin
ClientDataSet1CHECKED.AsString := 'Y';
Result := True;
end
else begin
ClientDataSet1CHECKED.AsString := 'N';
Result := False;
end;
finally
ClientDataSet1.Post;
end;
end;
procedure TForm719.TMSFMXGrid1FixedCellClick(Sender: TObject; ACol, ARow: Integer);
begin
if ARow >= TMSFMXGrid1.FixedRows then begin
case ACol of
DELETE:begin
TMSFMXGrid1.SelectRows(ARow, ARow);
ExcludeCurrent;
TMSFMXGrid1.UpdateGridCells;
end;
CHECKED:begin
TMSFMXGrid1.SelectRows(ARow, ARow);
if SwitchChecked then begin
TMSFMXGrid1.AddBitmap(CHECKED, ARow, 'BitmapCHECKED');
end
else begin
TMSFMXGrid1.AddBitmap(CHECKED, ARow, 'BitmapUNCHECKED');
//FView.ShowMessage('Elemento no seleccionado');
end;
TMSFMXGrid1.UpdateGridCells;
end;
end;
end;
end;
procedure TForm719.TMSFMXGrid1GetCellClass(Sender: TObject; ACol, ARow: Integer; var CellClassType: TFmxObjectClass);
begin
if ARow >= TMSFMXGrid1.FixedRows then begin
case ACol of
DELETE :CellClassType := TTMSFMXBitmapGridCell;
CHECKED :CellClassType := TTMSFMXBitmapGridCell;
end;
end;
end;