Recent

Author Topic: Add Dropdown list to Specific Stringgrid Cell  (Read 1134 times)

local-vision

  • Jr. Member
  • **
  • Posts: 77
Add Dropdown list to Specific Stringgrid Cell
« on: July 09, 2024, 09:24:06 pm »

Hi,

Adding a Picklist or otherwise a dropdown list of content to a StringGrid Column programatically can be achieved:

Code: Pascal  [Select][+][-]
  1.  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.


local-vision

  • Jr. Member
  • **
  • Posts: 77
Re: Add Dropdown list to Specific Stringgrid Cell
« Reply #2 on: July 09, 2024, 11:50:21 pm »
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

  • Hero Member
  • *****
  • Posts: 12867
Re: Add Dropdown list to Specific Stringgrid Cell
« Reply #3 on: July 10, 2024, 12:47:32 am »
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

  • Hero Member
  • *****
  • Posts: 6960
Re: Add Dropdown list to Specific Stringgrid Cell
« Reply #4 on: July 10, 2024, 12:52:17 am »
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.
The only true wisdom is knowing you know nothing

local-vision

  • Jr. Member
  • **
  • Posts: 77
Re: Add Dropdown list to Specific Stringgrid Cell
« Reply #5 on: July 10, 2024, 05:50:54 pm »
Big thanks to WP for the review, clear explanation and sample project! And, Jamie for the tip.

Again I have to mention that one of the things what makes Lazarus/Pascal so powerful (the secret weapon of choice) is its dedicated and problem solving community of quick response and skillful participants.

Making every attempt to improve on something that gets better and better.

 :)
« Last Edit: July 10, 2024, 06:21:39 pm by local-vision »

 

TinyPortal © 2005-2018