Re: Properties type


2003-07-24 09:25:40 PM
delphi272
You need to create a property editor.
Below is C++Builder code awhile ago (sorry I don't use Delphi) that displays
field names in a TDBMaskEdit component I wrote.
class PACKAGE TDBFieldPropertyEditor : public TStringProperty
{
typedef TStringProperty inherited;
private:
TDBMaskEdit* Comp;
public:
virtual TPropertyAttributes __fastcall GetAttributes(void);
virtual void __fastcall GetValues(Classes::TGetStrProc Proc);
__fastcall TDBFieldPropertyEditor(const _di_IFormDesigner ADesigner,
const int APropCount)
: TStringProperty(ADesigner, APropCount){}
virtual __fastcall ~TDBFieldPropertyEditor(void) { }
};
TPropertyAttributes __fastcall TDBFieldPropertyEditor::GetAttributes(void)
{
return inherited::GetAttributes() << paValueList>>paMultiSelect;
}
void __fastcall TDBFieldPropertyEditor::GetValues(Classes::TGetStrProc Proc)
{
TDBMaskEdit *Comp = (TDBMaskEdit*)GetComponent(0);
TStringList *TheFieldNames = new TStringList;
if(Comp->DataSource && Comp->DataSource->DataSet)
Comp->DataSource->DataSet->GetFieldNames(TheFieldNames); // get the
field names
else
TheFieldNames->CommaText = "";
if(TheFieldNames->Count == 0)
Proc("No Fields");
else
{
for(int i = 0; i < TheFieldNames->Count; i++)
Proc(TheFieldNames->Strings[i]);
}
delete TheFieldNames;
}
HTH
--
Malcolm Smith
MJ Freelancing- www.mjfreelancing.com
Software Protection for C++Builder
Borland Technology Partner
"Marco Azevedo" <XXXX@XXXXX.COM>writes
Quote


How can I create a String property that list TObjects information ?
For example into a ClientDataSet, the ProviderName property is String but
it lists all TDataSetProviders as well.

How does it do that ?

Thanks