Recent

Author Topic: DataSet Editor  (Read 2314 times)

J-23

  • Full Member
  • ***
  • Posts: 108
DataSet Editor
« on: September 04, 2020, 04:30:28 pm »
Hello,
I need to build a property similar to the DataSet property in the DataSource component - so that all child elements because of a given type are displayed in ComboBox, I tried to see how the DataSet property works in DataSource but I cannot find the code from this element. Will you suggest where to look?

PascalDragon

  • Hero Member
  • *****
  • Posts: 6033
  • Compiler Developer
Re: DataSet Editor
« Reply #1 on: September 04, 2020, 04:40:13 pm »
As long as the type of your property derives from TComponent it should work automatically.

If you want to display some custom type you need to take a look at TPropertyEditor in $lcl/components/ideintf/propedits.pp.

J-23

  • Full Member
  • ***
  • Posts: 108
Re: DataSet Editor
« Reply #2 on: September 04, 2020, 04:58:32 pm »
Yes, I know that, but what type of editor to choose?

e.g. a field of type String can be:
Code: Pascal  [Select][+][-]
  1. TStringProperty

And how to set for other types to work like the TDataset case?

Hence, I was looking for an example from TDataSet.


Sieben

  • Sr. Member
  • ****
  • Posts: 374
Re: DataSet Editor
« Reply #3 on: September 04, 2020, 05:12:37 pm »
You just define the type of your new property. The rest is handled automatically by the IDE resp. ObjectInspector. It knows what property editor to choose (unless you're doing sth real new and exotic). So for any descendant of TComponent you will get the usual combobox that is presented with TDataSet and others as well.
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

J-23

  • Full Member
  • ***
  • Posts: 108
Re: DataSet Editor
« Reply #4 on: September 04, 2020, 05:23:17 pm »
You just define the type of your new property. The rest is handled automatically by the IDE resp. ObjectInspector. It knows what property editor to choose (unless you're doing sth real new and exotic). So for any descendant of TComponent you will get the usual combobox that is presented with TDataSet and others as well.

I know that.

I only ask for the code as TDataSet does.

Sieben

  • Sr. Member
  • ****
  • Posts: 374
Re: DataSet Editor
« Reply #5 on: September 04, 2020, 05:27:26 pm »
PascalDragon already mentioned where to look...
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

J-23

  • Full Member
  • ***
  • Posts: 108
Re: DataSet Editor
« Reply #6 on: September 04, 2020, 06:04:08 pm »
PascalDragon already mentioned where to look...

I searched this site before I posted on the forum and I know that there are editor basics from which to build your own but TDataSet references are missing

I also typed in the search: "RegisterPropertyEditor"

Hoping the editor from TDataSet is registered somewhere similar to the TPictures type but with no effects. Hence my question on the forum.

Sieben

  • Sr. Member
  • ****
  • Posts: 374
Re: DataSet Editor
« Reply #7 on: September 04, 2020, 07:00:00 pm »
You mean like the property 'Pictur'e in TImage...? But TDataSource doesn't use any specific property editor, the property 'DataSet' in TDatasource is plain standard... 
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

J-23

  • Full Member
  • ***
  • Posts: 108
Re: DataSet Editor
« Reply #8 on: September 04, 2020, 09:39:52 pm »
\
You mean like the property 'Pictur'e in TImage...? But TDataSource doesn't use any specific property editor, the property 'DataSet' in TDatasource is plain standard... 

Yes. I mean the TPicture property from the TImage component.

I will try to describe what I want to do.

I have a collection where this collection is meant to be a dictionary for another property

This other property is to be a ComboBox similar to TDataSet in a DataSource component that will consist of data previously entered in the collection.

I know not the typical approach but building such a component will allow me to cut down a lot of code in later development.

Do you have an idea how to solve it?

Sieben

  • Sr. Member
  • ****
  • Posts: 374
Re: DataSet Editor
« Reply #9 on: September 04, 2020, 10:37:11 pm »
Did you have a look at the unit PropEdits mentioned above...?
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

J-23

  • Full Member
  • ***
  • Posts: 108
Re: DataSet Editor
« Reply #10 on: September 05, 2020, 10:16:52 am »
Did you have a look at the unit PropEdits mentioned above...?


Yes, I have looked and I know it.

However, the available editor basics do not allow me to do it the way I want, or I can't use it like that.

In the standard approach, TDataSet downloads to the Combobox all TDataSet-derived elements that are on the mold.
I want to do something like this:

I have Collections where I create any number of objects, eg TDataSetCollectionItem.

Where TDataSetCollectionItem comes from:
Code: Pascal  [Select][+][-]
  1. TDataSourceItem = class(TCollectionItem)

In the standard approach, I should do:
Code: Pascal  [Select][+][-]
  1. property DataSetCollectionItem: TDataSetCollectionItem read FDataSetCollectionItem write FDataSetCollectionItem
Putting the next TDataSetCollectionItem elements on the form, I would have a Combobox similar to TDataSet

The problem is that I want to keep these items in the collection, not on the form.

Hence my question at the beginning how TDataSet works to see how it works.






Sieben

  • Sr. Member
  • ****
  • Posts: 374
Re: DataSet Editor
« Reply #11 on: September 05, 2020, 11:14:55 am »
I still don't really get what you want, but there are a lot more property editor sources in ../components/ideintf, also including dbpropedits.pas and a number of editors using TCollections.
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

 

TinyPortal © 2005-2018