Recent

Author Topic: (SOLVED) - DBGrid - Column Editor  (Read 3942 times)

JZS

  • Full Member
  • ***
  • Posts: 194
(SOLVED) - DBGrid - Column Editor
« on: December 14, 2014, 09:24:52 am »
Hi,

I am interested in finding out how does Lazarus implemented one of the DBGrid functionality.
When you drop a DBGrid on a form you can click the Columns property, in the OI, and you get a window to manage the grid columns "Columns Editor", also you could double click on the grid and you get that same window.

All I want to know is how, if I have a component that has same property (TCollection), to populate the new window by dblclick on my component.

I already tried the wiki (TComponentEditor) but that assumes that I have a CustomFormEditor which I could pass my entries so the editing could be done and then when closed I update the list. But I see that is not the case in the DBGrid. It shows the same Editor and do not recreate a new window (I could be wrong).

I managed to generate the DefaultEvent, which is like when double clicking on an event to generate code, but how to do the same for properties?

I already managed to show a default window (attached) for my component to edit the list but how to show that window when double clicking the component?

My component is of class "TComponent" and the list is of class "TOwnedCollection" and I am not doing any thing extra to show the default editor for my list, I just define the published property under TComponent to be of Type TOwnedCollection Class, and there it is showing my list editor.

PS: It's a design time feature.
« Last Edit: December 15, 2014, 07:13:00 am by JZS »
I use recent stable release

JZS

  • Full Member
  • ***
  • Posts: 194
Re: DBGrid - Column Editor
« Reply #1 on: December 15, 2014, 03:22:11 am »
Is it that difficult?
I use recent stable release

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: DBGrid - Column Editor
« Reply #2 on: December 15, 2014, 06:01:40 am »
Try looking at Lazarus\components\ideintf\dbpropedits.pas, specifically:
Code: [Select]
initialization
...
  RegisterComponentEditor(TDBGrid,TDBGridComponentEditor);

Notice that TDBGridComponentEditor.ExecuteVerb gets the dbgrid it's dealing with through GetComponent and passes it to EditCollection.

ExecuteVerb's Index param is 0 for double-click/1st menu entry.

JZS

  • Full Member
  • ***
  • Posts: 194
Re: DBGrid - Column Editor
« Reply #3 on: December 15, 2014, 07:12:23 am »
Thank you Engkin, you are the best.
I use recent stable release

 

TinyPortal © 2005-2018