Forum > General
Add Dropdown list to Specific Stringgrid Cell
local-vision:
Hi,
Adding a Picklist or otherwise a dropdown list of content to a StringGrid Column programatically can be achieved:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- StringGrid1.Columns.Items[0].PickList.CommaText:='This,That,More,Less ';
This applied to all the cells in that column. All the cells in this column will have this dropdown list.
But what if:
1. You just want a specific cell to have that list and the others have no drop down list?
2. You want each cell in that column to have its own specific list content.
Any ideas? Thanks.
wp:
Read this: https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Grid_Cell_Editors.
Sample code: https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Example:_Working_with_Picklist,_How_to_make_it_read_only_and_How_to_fill_it_at_run_time
local-vision:
Appreciate the prompt reply and info.
Still reviewing the content. The example appears to be exactly what I am looking for.
However I am not able to get the working example to work.
The TCustomComboBox is not found. Do I need to create this somehow? Is there an example in which this code snippet is in a working project? I could then gain a better idea.
wp:
Shame on me that I did not see that this wiki code is broken (fixed it). The main issue was that it did not assign the predefined picklistcelleditor to the Editor parameter (by calling StringGrid.EditorByStyle(cbsPickList)).
Your issue with "TCustomCombobox not found" can be fixed by adding the unit StdCtrls to the uses clause.
Attaching the fixed wiki project.
jamie:
if you want to reject an editor to pop up at some cell Then set the EDITOR := Nil while in the OnSelectEditor.
Or change it to an editor of your choice.
Navigation
[0] Message Index
[#] Next page