FNCGrid - navigate to cells

How can I program to move to cells[ACol, ARow) ? I can't find any SelectCell / MoveToCell or similar. Anybody can pls. push me into the right direction?


With best regards

Hi, 


You can move to a cell (without selecting it) with:
  TMSFNCGrid1.Navigate(MakeCell(45, 45));
or you can move to and select a cell with
  TMSFNCGrid1.SelectCell(MakeCell(45, 45));

Hello,


I'm asking because I try to skip read only columns while moving through the grid by [Enter] or [Tab] key.

I tried this : (column 6 is readonly)

procedure TFormMain.FNCGridSelectCell(Sender: TObject; ACol, ARow: Integer;
  var Allow: Boolean);
begin
  if ACol=6 then
  begin
    Allow:= false;
    FNCGrid.Navigate(MakeCell(ACol+1, ARow),false);
  end
end;   

But the cursor stops in the column before the readonly column. Is there an event which is more useful for that?

With best regards



Hi, 


This feature is already built in under Options.Keyboard.EnterKeyHandling and Options.Keyboard.TabKeyHandling which internally verifies if the next cell is readonly / fixed or not and skips it automatically. If you still want to manage it programmatically you can retrieve the next selectable column / row with 

TMSFNCGrid1.NextSelectableRow(Col, Row) and/or TMSFNCGrid1.NextSelectableColumn(Col, Row)

Hello,


right now the cursor stops inside the readonly cell. I set the options as fallows :

    with options do
    begin
      Keyboard.EnterKeyHandling:= ekhNextColumn;
      Keyboard.EnterKeyDirectEdit:= true;

      Keyboard.TabKeyDirectEdit:= true;
      Keyboard.TabKeyDirection:= tkdNextColumnCell;
      Keyboard.TabKeyHandling:= tkhNextCell;
    end;     

    Columns[6].Width:= 75;
    Columns[6].HorzAlignment:= gtaTrailing;
    Columns[6].ReadOnly:= true;   

I tested it under Windows7 with Lazarus 1.6 - x64 / Lazarus trunk both with win32 and qt widgets

Another thing is, that whwn using the TAB key for navigating through the cells, its switching first off the edit mode and when presssing TAB a second time moving to the next cell.

Any options to avoid that? I would like to have the grid permanent in edit mode.

My best regards

Hi, 


We have investigated this here and were able to reproduce this issue. We have applied a fix for this issue and the next version will address this.

Thank you for this information, you are doing a great job! I have one another need for the grid navigation :


I'm not only defining columns/cells read only, I also would like to have columns/cells to skip when pressing TAB or ENTER key. Its like defining tab stops for columns/cells.

I started to extend the class TTMSFNCGridColumn by

property TabStop: boolean read FTabStop write FTabStop default true;    

I guess its easy to handle that in the same routine which checks for ReadOnly column/cell


With best regards

You can also block cell navigation by specifying if a cell is fixed or not:


procedure TForm1.TMSFNCGrid1GetCellIsFixed(Sender: TObject; ACol,
  ARow: Integer; var ACellFixed: Boolean);
begin
  ACellFixed := ACol = 2;
end;

The layout of the cell will change to a fixed layout, but this can easily be overriden in the OnGetCellLayout event

procedure TForm1.TMSFNCGrid1GetCellLayout(Sender: TObject; ACol,
  ARow: Integer; ALayout: TTMSFNCGridCellLayout;
  ACellState: TTMSFNCGridCellState);
begin
  if (ACol = 2) and (ARow >= TMSFNCGrid1.FixedColumns) then
  begin
    ALayout.Assign(TMSFNCGrid1.Appearance.NormalLayout);
  end;
end;

Ok, will try that. Will wait for the next bugfix version which adresses the key navigation issue.


Thank you for your help

Linux Mint 17.3 / Lazarus 1.6 / qt & gtk2 widgets / TMS FNC UI Pack v1.0.3.0


Hello,

after updating the package the only difference I noticed is, that when pressing TAB key its navigating in the same way as using the ENTER key except on the read only columns/cells.

TAB key : Still focus the read only column but move to the next column/cell on the next TAB key press

ENTER key : Focus the read only column/cell and stays there 

Just to be sure that I upgraded to the correct package : The grid has the version 1.0.0.5


WIth best regards

Hi, 


The behavior is by design, a readonly cell can be navigated to, with the TAB key and Enter key.
The issue we have fixed is that the TAB Key or Enter key wouldn't navigate to the next cell. To skip readonly cells you need to set the cell to fixed, via the code below. A fixed cell has a different appearance, so you need to override this as well:

procedure TForm1.TMSFNCGrid1GetCellIsFixed(Sender: TObject; ACol,
  ARow: Integer; var ACellFixed: Boolean);
begin
  ACellFixed := TMSFNCGrid1.Columns[ACol].ReadOnly;
end;

procedure TForm1.TMSFNCGrid1GetCellLayout(Sender: TObject; ACol, ARow: Integer;
  ALayout: TTMSFNCGridCellLayout; ACellState: TTMSFNCGridCellState);
begin
  if (ACellState = csFixed) and TMSFNCGrid1.Columns[ACol].ReadOnly and (ARow >= TMSFNCGrid1.FixedRows) then
    ALayout.Assign(TMSFNCGrid1.Appearance.NormalLayout);
end;

When applying this code, the readonly cells will be skipped when tabbing or pressing enter

Hello,

I guess that was a misunderstanding from the previous posting obove.

Best regards

Hello,


is the TMSFNCGrid1.Navigate(MakeCell(PosX, PosY));

working at all? Even without any ReadOnly column/cell, its seems that the current cell is not changing(?)

The method TMSFNCGrid.EditCell(MakeCell(PosX,PosY));

however is doing what I expect, move to the wanted cell and brings it into edit mode.

Any misunderstanding on my side what the Navigate() method should do?

WIth best regards

Hi, 


The Navigate is only showing the cell, if the cell is out of range it will automatically scroll, but not select the cell. When there is no scrolling involved Navigate will not change the grid visually. To select the cell you need to use TMSFNCGrid1.SelectCell(MakeCell(45, 45)); which calls Navigate internally.

Hello,


thank you for your quick response. I guess I got it now. That is also the reason why the event OnSelectCell() is not occuring after executing Navigate()

I guess originally I was looking for the EditCell() method, to move to the wanted column/cell

Best regards