Board index » cppbuilder » About TPropertyEditor::GetValue and SetValue

About TPropertyEditor::GetValue and SetValue

Hi to All !

I've created a property editor to give the user the possibility to choose
and select a value from a drop-down list of values in a property field in
the object inspector ; these values come from a TStringList (using
TGetStrProc in overrided GetValues).
I can see the list when clicking on the right arrow in the property field,
but when I select a value, it doesn't "stay". I must have a mistake in
overriding GetValue and SetValue, but, as a beginner in creating components,
I don't see where.
In the implementation file, I've written something like that :

AnsiString __fastcall TMyPropertyEditor::GetValue()
{
    return GetStrValue();

Quote
}

void __fastcall TMyPropertyEditor::SetValue(const AnsiString Value)
{
    if (MyList->IndexOfit(Value) > -1
    {
        SetStrValue(Value);
    }
    else
    {
        ShowMessage("Invalid property value");
    }

Quote
}

Great thanks to You All !
Jean-Louis
 

Re:About TPropertyEditor::GetValue and SetValue


When and how your MyList filled?  What does your header file look like?

Gambit

Quote
"Jean-Louis Brabant" <jl.brab...@wanadoo.fr> wrote in message

news:3e8862c2@newsgroups.borland.com...
Quote
> I can see the list when clicking on the right arrow in the property
> field, but when I select a value, it doesn't "stay". I must have a
> mistake in overriding GetValue and SetValue, but, as a beginner
> in creating components, I don't see where.

Re:About TPropertyEditor::GetValue and SetValue


Hi, Remy !
Here is what is define in the h.file :

class PACKAGE TMyPropertyEditor : public TPropertyEditor
{
protected:
          TStringList* MyList;
public:
       TMyPropertyEditor __fastcall(const _di_IFormDesigner ADesigner, int
APropCount);
       virtual __fastcall ~TMyPropertyEditor();
       TPropertyAttributes __fastcall GetAttributes();
       void __fastcall GetValues(Classes::TGetStrProc Proc);
       AnsiString __fastcall GetValue();
       void __fastcall SetValue(const AnsiString Value);

Quote
};

MyList is created in TMyPropertyEditor's constructor and destructed in
TMyPropertyEditor's destructor.
Here is the implementation code for GetValues :
void __fastcall TMyPropertyEditor::GetValues(TGetStrProc Proc)
{
  for (int i = 0; i < MyList->Count; i++)
  {
      Proc(MyList->Strings[i]);
  }
  TPropertyEditor::GetValues(Proc);

Quote
}

Thanks to you,
Jean-Louis
"Remy Lebeau (TeamB)" <gambi...@yahoo.com> a crit dans le message de news:
3e88862...@newsgroups.borland.com...
Quote
> When and how your MyList filled?  What does your header file look like?

> Gambit

Other Threads