Stringgrid: Inplace editor with TDatetime; tab not working probably lazarus / 31-LCL ---------------------------------------------------------------------- MoellerCLaus · 2013-10-17 06:23 New to Lazarus and right now porting an app from Delphi. I do use StringGrid for editing data and one of the fields needs to be a date. So I use TDatetime and it works fine. The Grid options is set to goAlwaysShowEditor, goEditing, goTabs. Unfortunately pressing the tab will not leave datetime when editing and proceed to next column. Any ideas where to look Code: [Select]procedure TKasseKladdeForm.StringGrid1SelectEditor(Sender: TObject; aCol,   aRow: Integer; var Editor: TWinControl); begin   If      aCol = KasBL Then     Begin       Editor := StringGrid1.EditorByStyle(cbsAuto);       //Editor := StringGrid1.EditorByStyle(cbsPickList);       //TCustomComboBox(Editor).Items.CommaText := 'A,B,C,D';     end   Else If acol = KasDato Then     Begin       try         DateEdit1.BoundsRect := StringGrid1.CellRect(aCol,aRow);         If StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row] <> '' Then           DateEdit1.Date := StrToDate(StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]);         Editor := DateEdit1;       Except       end;     end ---------------------------------------------------------------------- bigeno · 2013-10-17 10:05 Code: [Select]procedure TForm1.DateEdit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin  if Key=9 then begin     StringGrid1.EditorMode:=false;     if (StringGrid1.Col+1) < StringGrid1.ColCount then        StringGrid1.Col:=StringGrid1.Col+1;  end; end; ---------------------------------------------------------------------- MoellerCLaus · 2013-10-17 14:45 Thanks BIgEno for your suggestion and helping me on the right track I ended with this in DateEdit1KeyDown Code: [Select]   if Key=9 then     begin       StringGrid1.EditorMode := false;       if StringGrid1.Col < StringGrid1.ColCount then          StringGrid1.Col := StringGrid1.Col + 1       Else         StringGrid1.Col := 0;       StringGrid1.SetFocus;     end;     end; ---------------------------------------------------------------------- ademir.uem · 2016-04-04 14:07 It is a bug? If we try this lazarus demos : gridcelleditor we will see that when we press TAB or Enter it does not work correctly. Even the Grid options is set to goAlwaysShowEditor, goEditing, goTabs. I cant beleive this Where is the problem? ---------------------------------------------------------------------- wp · 2016-04-04 15:14 Quote from: ademir.uem on April 04, 2016, 04:07:46 pmWhere is the problem? No idea. For me it is working fine. Please post a little demo which shows the isse (only .lfm, .pas, .lpi and .lpr files, packed into a single zip). ---------------------------------------------------------------------- ademir.uem · 2016-04-04 17:00 Please, use that example (demo) I cited : gridcelleditor.lpi  into the lazarus directory.  Set the grid to goAlwaysShowEditor, goEditing, goTabs. Compile and use TAB button to "walk" though cells. You will see the problem when arrive in columns 3 (acol=3) where is used a combobox. You press tab but does not leave (walk to nex cell). I use Lazarus 1.6, 32bits on Windows 10. ---------------------------------------------------------------------- wp · 2016-04-04 17:28 This demo seems to be out-dated. If you look at the wiki (http://wiki. lazarus.freepascal.org/Grids_Reference_Page#Grid_Cell_Editors) you'll find the correct usage of a picklist cell editor: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.StringGrid1SelectEditor(Sender: TObject; aCol, aRow: Integer;  var Editor: TWinControl);begin  if (aCol=3) and (aRow>0) then begin  Editor := StringGrid1.EditorByStyle(cbsPickList);    if (Editor is TCustomComboBox) then      with Editor as TCustomComboBox do        Items.CommaText := 'A,B,C';  end;end; And remove the OnEditingDone event handler, the picklist cell editor takes care of data transfer into the cell. If you navigate with the keyboard use Alt+Down to open the picklist. ---------------------------------------------------------------------- ademir.uem · 2016-04-04 18:33 But if you change Combobox for another componente, as Edit, SpinEdit, DateEdit, etc. the problem is repeated. ---------------------------------------------------------------------- wp · 2016-04-04 20:28 OK, I see. The built-in cell editors contain code to pass the TAB to the grid, the stand-alone combobox of the demo does not have it. Add this OnKeyDown event handler to the combobox, and the tab will work: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TMyGrid = class(TCustomGrid); procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);begin  if Key = 9 then    // some hack to pass the key to the grid    TMyGrid(StringGrid1).KeyDown(Key, Shift);end; TSpinEdit, DateEdit etc. will work the same way, they can share the same OnKeyDown handler.