Adding comboboxes to cells in an FPSpreedsheet lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- jdaz2000 · 2023-07-07 22:43 Does anyone know a way that I can make all the cells in a FPSpreadsheet column comboboxes with each combobox have the same items?  I want to limit the selection choice for a particular column. ---------------------------------------------------------------------- wp · 2023-07-07 23:15 The TsWorksheetGrid is a TCustomGrid after all, and thus many of the techniques used for TCustomGrid (or TStringGrid) may work for TsWorksheetGrid, too. The Grids-wiki describes how a different cell editor can be selected (https://wiki.lazarus.freepascal.org/Grids_Refe rence_Page#Grid_Cell_Editors) - do the same with the worksheet grid: 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.sWorksheetGrid1SelectEditor(Sender: TObject; aCol,  aRow: Integer; var Editor: TWinControl);begin  if (aCol = 3) then  begin    Editor := sWorksheetGrid1.EditorByStyle(cbsPickList);    with TPickListCellEditor(Editor) do    begin      Style := csDropDownList;      Items.StrictDelimiter := true;      Items.CommaText := 'Africa,Asia,Europe,North America,Oceania,South America';    end;  end; end;This code is the handler for the grid's OnSelectEditor event.The line "Editor := sWorksheetGrid1.EditorByStyle(cbsPickList)" selects a picklist cell editor (combobox) for the cells defined in the preceeding "if" condition (here: all cells of column 3)."TPickListCellEditor(Editor).Items.CommaText" defines the items in the combobox as a comma-separated list, here: the earth's continents. Since the items "North America" and "South America" contain spaces we must switch StrictDelimiter to true, otherwise the ComboBox would split these items at the space and add "North", "South" and "America" as separate items. Depending on the leading "if" condition you can use different item lists for specific cells."Style := csDropdownList" disables direct typing for the user.If you don't like the thick border of the selected cell interfering with the combobox you could additionally call "sWorksheetGrid1.SelectionPen.Style := psClear" in the OnSelectEditor handler - this hides the selection rectangle while the combobox is visible. The counter-part,  "sWorksheetGrid1.SelectionPen.Style := psSolid", then should be called in the OnEditingDone event of the grid in order to restore the selection rectangle. ---------------------------------------------------------------------- jdaz2000 · 2023-07-08 13:41 Thanks for your help.  I really appreciate it. ---------------------------------------------------------------------- jdaz2000 · 2023-07-08 16:43 I rookie question but I can't find an answer.  I created a test app and placed a single TsWorkSheetGrid control on Form1.  On the Events tab in Object Inspector I have sWorksheetGrid1SelectEditor showing the OnSelectEditor line. However, when I run it and click on any cell in the grid the procedure TForm1.sWorksheetGrid1SelectEditor is never triggered. Can't figure out what I'm doing wrong. ---------------------------------------------------------------------- wp · 2023-07-08 16:46 Did you activate the goEditing option? By default, the LCL grids are read-only, and the cell editor will not show. You must set this flag to make them editable. ---------------------------------------------------------------------- jdaz2000 · 2023-07-08 17:12 That was it, thanks so much. You are very kind to help. ---------------------------------------------------------------------- Allam · 2023-07-08 17:19 The best option is to install Rx lib from onlinepackagemanager  . it contain FPSpreedsheet and ZeosDB with Rx you can use dbgridview with auto filter like Excel and Export the dbgrid to Excel in a second .... it is very very usefull I am sory for my English ---------------------------------------------------------------------- jdaz2000 · 2023-07-08 17:25 Thanks for the suggestion.  I'll take a look at it. ---------------------------------------------------------------------- wp · 2023-07-08 17:27 Since a WorksheetGrid just placed on a form has the default property values inherited you probably should adjust also other settings which I had listed in the wiki article about the grid: https://wiki.lazarus. freepascal.org/TsWorksheetGrid#Recommended_property_values ---------------------------------------------------------------------- jdaz2000 · 2023-07-08 17:54 Great help! Thanks very much. ---------------------------------------------------------------------- jdaz2000 · 2023-07-10 17:52 Not having much luck finding documentation for TsWorkSheets with comboboxes so here is another question. Can someone tell me how to set the item index value for a ComboBox in a particular Cell in a TsWorkSheetGrid? ---------------------------------------------------------------------- jdaz2000 · 2023-07-10 18:41 Figured it out.       MyPickListCellEditor := TPickListCellEditor(sWorkSheetGrid1.EditorByStyle(cbsPickList));       sWorkSheetGrid1.Cells[1,1]:=MyPickListCellEditor.Items[1]; ---------------------------------------------------------------------- jwdietrich · 2023-07-11 06:32 In the SimulaBeta project, you may find working examples that don't require external libraries for the GUI. They are implemented in the sequencer window (sequencer.pas and sequencer.lfm). The source code is available from SourceForge and GitHub.