• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

How to Create a DB component with FIELD selector

Hi, I want to create a DB component where I select the Datasource. That works correctly, but when I want to select the FIELD (TFIELD) I get a list of ALL fields. I only want to have the fields from the source I've selected in the object inspector.

Anyone knows How?
0
Avataris
Asked:
Avataris
  • 6
  • 4
1 Solution
 
TOndrejCommented:
Have a look in DBReg unit...

RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TDataFieldProperty);

This means that TDataFieldProperty property editor is registered for all string properties called 'DataField' of all TComponent descendants.

I guess your component is a TComponent descendant <g>.
Is your property of type string?
Is it called 'DataField'?

IOW, does the declaration look similar to the following:

property DataField: string read GetDataField write SetDataField;

??

Please be more specific, and show us how the property is declared and any other info you think might be useful.
From the symptoms you describe it seems that your property is of type TField... but I don't want to guess for no good reason.

TOndrej
0
 
AvatarisAuthor Commented:
Yes the property is declared like that, I want to have a combobox with the fields from the table in the property editor.
0
 
AvatarisAuthor Commented:
I don't have a DBREG anything :(
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
TOndrejCommented:
Please show me the exact declaration and get/set methods and the internal field declaration.
0
 
AvatarisAuthor Commented:
But I think i get your point :)
I'll test it now.
0
 
TOndrejCommented:
I have it in <delphidir>\Source\Property Editors\dbreg.pas
(Delphi 5 Enterprise)
0
 
AvatarisAuthor Commented:
Thanx, this method :

RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TDataFieldProperty);


Is all I needed :)
0
 
TOndrejCommented:
It's strange that you needed it.

Anyway... You don't seem to be interested in a complete solution. Good luck.
0
 
AvatarisAuthor Commented:
Thanx, this method :

RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TDataFieldProperty);


Is all I needed :)
0
 
AvatarisAuthor Commented:
I don't have Delphi 5, just Delphi 4.
Delphi 4 has no examples about the subject.
Complete solutions take the fun of programming away ;)

But my component works fine now :)
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now