i tried but it does not work as expected :-(
when i see the code you wrote, it seems that an event is also added.
is it like that for all properties ? because i've not seen it till now.
moreover, where did you find the code below ? in help ?
i did not find it..
thx.
Al.
Lloyd Dupont wrote:
Well why don't you try the "DefaultValueAttribute" as I told you?
I think it's exactky what you need!
Anyway, FYI, here is what reflector says about Control.BackgroundImage:
[System::ComponentModel:
efaultValue(*static_cast<__box
System::String*>(0)), System::ComponentModel::Localizable(true),
System::Windows::Forms::SRDescription(S"ControlBackgroundImageDescr"),
System::Windows::Forms::SRCategory(S"CatAppearance")]
public: __property virtual System:
rawing::Image __gc*
get_BackgroundImage()
{
return *static_cast<__box
System:
rawing::Image*>(this->Properties->GetObject(System::Windows::Forms::Control:
ropBackgroundImage));
}public: __property virtual void __gc*
set_BackgroundImage(System:
rawing::Image __gc* value)
{
if (this->BackgroundImage != value)
{
this->Properties->SetObject(System::Windows::Forms::Control:
ropBackgroundImage,
value);
this->OnBackgroundImageChanged(System::EventArgs::Empty);
}
}
My problem is not to assign a value to this property. I think it it
how to clear it, if user press DELETE, BACKSPACE keys when this
property has the focus in the property editor.
For example if i assign a bitmap to form thanks backgroundimage
property, just by pressing delete, this property is cleared.
i would like to have the same for my property..
that's all
Al.
Lloyd Dupont wrote:
You could try the
DefaultValueAttribute instead...
Thanks Carl, but i went to this direction according to my other
issue...
when i assigned a bitmap to this property, it's ok and everything
works.
However, once a bitmap is assigned, and i want to delete this
assignment, i usually use select the property value in property
editor and press delete key...
it clear the property field value and it should display (none) as
usual...
but nothing happens... since i assign a bitmap, i can not have
anymore this property field value to (none). I can only assign
another bitmap, but never clear the field :-(
do you have an idea ?
thx.
Al.
Carl Daniel [VC++ MVP] wrote:
--== Alain ==-- wrote:
here is my code :
#pragma region public Property : ImageSortAscendant
// Allow user to select the image which will be displayed for
column
sorted ascendantly
[System::ComponentModel:
efaultPropertyAttribute (nullptr)]
property Bitmap^ ImageSortAscendant
{
Bitmap^ get()
{
return m_ImageSortA;
}
void set(System:
rawing::Bitmap^ value)
{
m_ImageSortA = value;
}
}
#pragma endregion
but when i try to compile, i have the following error :
..\RAF_ListView.h(177) : error C3115:
'System::ComponentModel:
efaultPropertyAttribute': this attribute
is
not allowed on 'RAF_ListView::AR_ListView::ImageSortAscendant'
how could it be possible ?
It's not necessary. If you simply don't assign a value to the
property (or the private field that backs it up), then it WILL be
null.
The DefaultProperty attribute is applied to a class and names the
default property of the class. It does not provide a default value
for a property, which is apparently what you're trying to do.
-cd