editable image property ?

  • Thread starter Thread starter --== Alain ==--
  • Start date Start date
A

--== Alain ==--

Hi,

I would like to have a property of image type.

i've seen on official .NET component that several controls have such
properties.

My component is built under VC++.NET and not under C#, but as codes are
similar and i did not get any help from relative forum, i'm asking here.

So, i do not have any problem with my component except 1 thing.
When an image is already allocated, i can not delete it or destroy the
bundling with the property by replacing "System.Drawing.Bitmap" with
"(none)".
the (none) appears when i directly edit and erase everything (all
characters) from the image property editor.

in my component it's impossible...
i was thinking to convert my type image to a string (to be able to edit
it in property editor) and after to convert it back, but i would be very
surprised if this is the solution.

please, could you advise me ?

thanks a lot,

Alain
 
Hi Alain,

Assuming you're using VS 2005 add the following to your property (C#):

[DefaultValue(null)]
public Bitmap MyBitmap { get { return bitmap } set { bitmap = value; } }

In the property window you can select the text and press the delete key or you
can right-mouse click and select "Reset".
 
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::DefaultPropertyAttribute (nullptr)]
property Bitmap^ ImageSortAscendant
{
Bitmap^ get()
{
return m_ImageSortA;
}
void set(System::Drawing::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::DefaultPropertyAttribute': this attribute is
not allowed on 'RAF_ListView::AR_ListView::ImageSortAscendant'

how could it be possible ?
if i understood well, [DefaultValue(null)] was available on .net v1 only.

thanks,

Al.
 
Hi Alain,
but when i try to compile, i have the following error :
..\RAF_ListView.h(177) : error C3115:
'System::ComponentModel::DefaultPropertyAttribute': this attribute is not
allowed on 'RAF_ListView::AR_ListView::ImageSortAscendant'
how could it be possible ?

I searched MSDN for C3115 - I think you are misusing the attribute.

Attribute Usage on MSDN:
http://windowssdk.msdn.microsoft.com/en-us/library/0b34zz73.aspx

Apparently your example is not the correct way to declare public properties so
that they can use managed attributes. In the link I posted above there is no
reference to public properties at all so I'm not sure how you can accomplish
that (although there is mention of attributes on methods, which I believe is
the direction you'll probably need to go)

Your idea that C# is similar enough to C++ and asking your questions in this
newsgroup isn't going to help you solve your problems. You're probably much
better off finding some managed C++ resources and taking some time to read
them.
if i understood well, [DefaultValue(null)] was available on .net v1 only.

DefaultValueAttribute is still alive and well in the 2.0 framework. I use it
all the time.

--
Dave Sexton

--== Alain ==-- said:
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::DefaultPropertyAttribute (nullptr)]
property Bitmap^ ImageSortAscendant
{
Bitmap^ get()
{
return m_ImageSortA;
}
void set(System::Drawing::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::DefaultPropertyAttribute': this attribute is not
allowed on 'RAF_ListView::AR_ListView::ImageSortAscendant'

how could it be possible ?
if i understood well, [DefaultValue(null)] was available on .net v1 only.

thanks,

Al.


Dave said:
Hi Alain,

Assuming you're using VS 2005 add the following to your property (C#):

[DefaultValue(null)]
public Bitmap MyBitmap { get { return bitmap } set { bitmap = value; } }

In the property window you can select the text and press the delete key or
you can right-mouse click and select "Reset".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top