Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-02

Is this bug ? or how to do?

12 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

FreeMan

Hello,
I'm writeing my exlookup component, I add 2 datasource and 3 field. Like a dblookupcombobox.
my component's properties:

     FDataField : TFieldDataLink;
     FListField : TFieldDataLink;
     FKeyField  : TFieldDataLink;

On Objectinspector, property editor work just for, if Property name is "DataField" my idea is propertyeditor check property name('datafield')not classname or type "TFieldDataLink" . I mean fieldlist combobox work on OI just if propertyname is "datafield". second or third field name not listing, just string edit, not combobox. this is same on "TDBLookupComboBox".
Is this bug or I have to use some code for this.
Thank you.

Reply by email

Mattias Gaertner
to FreeMan
Show quoted text 11 lines
Hello, I'm writeing my exlookup component, I add 2 datasource and 3 field. Like a dblookupcombobox. my component's properties: FDataField : TFieldDataLink; FListField : TFieldDataLink; FKeyField : TFieldDataLink; On Objectinspector, property editor work just for, if Property name is "DataField" my idea is propertyeditor check property name('datafield')not classname or type "TFieldDataLink" .

Somehow the sentence is mangled. Can you rephrase it please?

Show quoted text 6 lines
I mean fieldlist combobox work on OI just if propertyname is "datafield". second or third field name not listing, just string edit, not combobox. this is same on "TDBLookupComboBox". Is this bug or I have to use some code for this. Thank you.

Mattias

Reply by email

FreeMan
to Mattias Gaertner

Put TDBLookupComboBox on form, add 2 tdatasource & Ttable or Tquery. And add datasources to TDBLookupComboBox.ListSource and TDBLookupComboBox.DataSource, after then select DataField property, (on Objectinspecter open fieldlist). "KeyField" and "ListField" property not open fieldlist on ObjectInspecter.

27-02-2014 12:50 tarihinde, Mattias Gaertner yazd?:

Somehow the sentence is mangled. Can you rephrase it please?

Reply by email

Martin Frb
to FreeMan: I'm writeing my exlookup component, I add 2 datasource and 3 field. Like a…
FreeMan wrote 17 lines
Hello, I'm writeing my exlookup component, I add 2 datasource and 3 field. Like a dblookupcombobox. my component's properties: FDataField : TFieldDataLink; FListField : TFieldDataLink; FKeyField : TFieldDataLink; On Objectinspector, property editor work just for, if Property name is "DataField" my idea is propertyeditor check property name('datafield')not classname or type "TFieldDataLink" . I mean fieldlist combobox work on OI just if propertyname is "datafield". second or third field name not listing, just string edit, not combobox. this is same on "TDBLookupComboBox". Is this bug or I have to use some code for this. Thank you.

you are missing:

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

see
components\ideintf\dbpropedits.pas

Reply by email

FreeMan
to Martin Frb

Thank you Martin, I was forget and checked it that. I add this lines and now field list opening.
RegisterPropertyEditor(TypeInfo(string), TExLookUp, 'DataField', TFieldProperty);//DataSource := Dataset1
RegisterPropertyEditor(TypeInfo(string), TExLookUp, 'ListField', TFieldProperty);//ListSource := Dataset2
RegisterPropertyEditor(TypeInfo(string), TExLookUp, 'KeyField', TFieldProperty);//ListSource := Dataset2

But: :) in components\ideintf\dbpropedits.pas
procedure TFieldProperty.FillValues(const Values: TStringList);
var DataSource: TDataSource;
begin
   DataSource := GetObjectProp(GetComponent(0), 'DataSource') as
TDataSource;
   LoadDataSourceFields(DataSource, Values);
end;

GetComponent(0) function is return my component "TExLookUp", this is okey. But I have 2 Datasource Property:

published
    property DataField: string read GetDataField write
SetDataField;//Accually people use same propertyname
    property DataSource: TDataSource read GetDataSource write
SetDataSource;//Accually people use same propertyname
    property KeyField: string read Get_KeyField write Set_KeyField;
    property ListField: string read Get_ListField write Set_ListField;
    property ListSource: TDataSource read Get_ListSource write
Set_ListSource;

TFieldProperty.FillValues function lookingfor in my root component, only (string type)'DataSource' property.

For test:
property DataSourcex: TDataSource read GetDataSource write SetDataSource; I change property name 'DataSource' to 'DataSourcex', when click to DataField property, this error popup.

Unknown property: "DataSource".

Press OK to ignore and risk data corruption.

Press Cancel to kill the program.

Any idea ?

27-02-2014 21:44 tarihinde, Martin Frb yazd?:

Show quoted text 8 lines
you are missing: RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TFieldProperty); see components\ideintf\dbpropedits.pas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140228/5f8871ee/attachment-0001.html>

Reply by email

Martin Frb
to FreeMan
FreeMan wrote 17 lines
Thank you Martin, I was forget and checked it that. I add this lines and now field list opening. RegisterPropertyEditor(TypeInfo(string), TExLookUp, 'DataField', TFieldProperty);//DataSource := Dataset1 RegisterPropertyEditor(TypeInfo(string), TExLookUp, 'ListField', TFieldProperty);//ListSource := Dataset2 RegisterPropertyEditor(TypeInfo(string), TExLookUp, 'KeyField', TFieldProperty);//ListSource := Dataset2 But: :) in components\ideintf\dbpropedits.pas procedure TFieldProperty.FillValues(const Values: TStringList); var DataSource: TDataSource; begin DataSource := GetObjectProp(GetComponent(0), 'DataSource') as TDataSource; LoadDataSourceFields(DataSource, Values); end;

I am no expert on this, so I cant give you much more help. But it looks you need to write your own property editor.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140228/20d9df54/attachment.html>

Reply by email

FreeMan
to Martin Frb

I have a solution: (I get idea from Delphi_XE2/IDE/source/Property Editors/DBReg.pas)

type
   TFieldProperty = class(TStringPropertyEditor)
   public
      function Get_DataSource_Name: string; virtual;
...........
function TFieldProperty.Get_DataSource_Name: string;
begin
     Result := 'DataSource';//Default name
end;
procedure TFieldProperty.FillValues(const Values: TStringList);
var
   DataSource: TDataSource;
begin
   DataSource := GetObjectProp(GetComponent(0), *Get_DataSource_Name * )
as TDataSource;
   LoadDataSourceFields(DataSource, Values);
end;

Who wana use different datasource name, add just this codes own source(s).

   TMyFieldProperty = class(TFieldProperty)
   public
     function Get_DataSource_Name: string; override;
   end;
implementation
function TMyFieldProperty.Get_DataSource_Name: string;
begin
     Result := 'Rock_Data_Roll_Source';// :) what you want
end;
initialization
   RegisterPropertyEditor(TypeInfo(string), TExLookUp,
'LookInThisField', TMyFieldProperty);

I wantto make patch for this, but I saw TFieldProperty class used other codes, so best way is lazarus team add this.
I hope lazarus team answer to my soulution accept or not. Thank you

28-02-2014 19:13 tarihinde, Martin Frb yazd?:

I am no expert on this, so I cant give you much more help. But it looks you need to write your own property editor.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140301/6965cd81/attachment.html>

Reply by email

Martin Frb
to FreeMan
FreeMan wrote
I have a solution: (I get idea from Delphi_XE2/IDE/source/Property Editors/DBReg.pas)

Please never post anything you got from looking at Delphi's source code. You may be violating their copyright.

Unfortunately since you have looked at it, and your solution is now influenced by knowledge of their intellectual property, we will not be able to accept a patch from you on this issue.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140301/84217568/attachment.html>

Reply by email

FreeMan
to Martin Frb

I understood, I'm not lawyer, I'm sure you expert then me about this. I understanding from this message, who use "antique greek city name" (this is be wrong too) who use "antique Hellenic city name" can NOT write any code,can NOT any developing about that class, 'cos that knowledge from them. We never user "antique Hellenic city name" 'cos trademarked to them.
I was just look on internet, "antique Hellenic city name" has same problem. How I prove, I wrote my solution before look them code? never. I'm really bored. nevermind

Please do NOT understand this my message like , "why not accept my solution" It was my mistake. so my first word "I understood". Antique hellenic city name will lost :)
Thank you Martin, I learned one more think.

01-03-2014 13:22 tarihinde, Martin Frb yazd?:

Show quoted text 11 lines
On 01/03/2014 10:52, FreeMan wrote: > I have a solution: (I get idea from Delphi_XE2/IDE/source/Property > Editors/DBReg.pas) Please never post anything you got from looking at Delphi's source code. You may be violating their copyright. Unfortunately since you have looked at it, and your solution is now influenced by knowledge of their intellectual property, we will not be able to accept a patch from you on this issue.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140301/4327fed7/attachment.html>

Reply by email

Martin Frb
to FreeMan
FreeMan wrote 14 lines
I understood, I'm not lawyer, I'm sure you expert then me about this. I understanding from this message, who use "antique greek city name" (this is be wrong too) who use "antique Hellenic city name" can NOT write any code,can NOT any developing about that class, 'cos that knowledge from them. We never user "antique Hellenic city name" 'cos trademarked to them. I was just look on internet, "antique Hellenic city name" has same problem. How I prove, I wrote my solution before look them code? never. I'm really bored. nevermind Please do NOT understand this my message like , "why not accept my solution" It was my mistake. so my first word "I understood". Antique hellenic city name will lost :) Thank you Martin, I learned one more think.

- You can *use* it. There is no conflict.
- You are *not* allowed to *look* at its sources, in order to write code for Lazarus.

http://en.wikipedia.org/wiki/Clean_room_design
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140301/3719f3e0/attachment.html>

Reply by email

Mattias Gaertner
to Martin Frb

TFieldProperty.FillValues is virtual and has only two lines of code. The default implementation searches a property named 'DataSource'. You can override it to fetch DataSource from many different sources: For example from any property with type TDataSource, or depending on the selection or from the form or whatever ...

I made the formerly hidden function LoadDataSourceFields public as ListDataSourceFields, so you can implement any of the above easily. Including using another property name than 'DataSource'.

Mattias

Reply by email

FreeMan
to Mattias Gaertner

I tested, one word, PERFECT
Thank you Mattias

01-03-2014 18:24 tarihinde, Mattias Gaertner yazd?:

Show quoted text 19 lines
TFieldProperty.FillValues is virtual and has only two lines of code. The default implementation searches a property named 'DataSource'. You can override it to fetch DataSource from many different sources: For example from any property with type TDataSource, or depending on the selection or from the form or whatever ... I made the formerly hidden function LoadDataSourceFields public as ListDataSourceFields, so you can implement any of the above easily. Including using another property name than 'DataSource'. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email