473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DefaultValues for enums and objects?

Hi

I'm using the PropertyGrid control, and implemented a popup menu to Reset properties, like the IDE
The problem I have is that I'm unable to specify DefaultValues for enums and objects
For example, given the following enum (inside a __gc class)

__value enum Fo

One = 1
Two = 2
Three =
}

[ DefaultValue(One)
__property Foo get_Prop() { return m_enum;
__property void set_Prop(Foo value) { m_enum = value;

Gives the following erro

c:\Documents and Settings\Neo\My Documents\Visual Studio Projects\Modeler\Form1.h(212): error C2363: cannot evaluate argument 'One' of custom attribute 'System::ComponentModel::DefaultValueAttribute

I also tried wit

[ DefaultValue(1)

[ DefaultValue("1")

an

[ DefaultValue("One")

But then it raises a runtime exception

System.ArgumentException: Object type cannot be converted to target typ

* *

Also I have problems with a property of type Image. How to Reset in those cases

In this case, the objects initializes the Image field to NULL, and the PropertyGrid displays a white square with the legend "(empty)". But if I us

[ DefaultValue(NULL)

The same exception as before is raisen

The code that I'm using to reset the property value to its default value is

propertyGrid1->SelectedGridItem->PropertyDescriptor->ResetValue(propertyGrid1->SelectedObject)

Any idea someone?
Nov 17 '05 #1
0 1008

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
4
by: David Rasmussen | last post by:
The problem comes up in all sorts of contexts. But here is an example: We want to model the basics of chess, maybe for making a chess program, or maybe just to make an interactive board or ... ...
4
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
5
by: Hans Kesting | last post by:
Hi, In a database some code is stored as a string. This code can have a limited (known) set of values. What is the best way to use this in my (program-)code? I don't want to use "magic codes"...
3
by: bshumsky06 | last post by:
Hi, I am trying to parse some text into c# commands using reflection. I am new to this so there may be a simpler way of doing things. Anyhow, the below code works fine except for enums. ...
37
by: Ian Semmel | last post by:
If I have Enum en { i1, i2, i3 } I reckon I should be able to have
8
by: Daniel Gutson | last post by:
Hi, I just wanted to share another library for doing type-safe bitwise operations in C++: http://bitwise-enum.googlecode.com I found it useful, so hopefully it'll be for somebody else as well....
13
by: aarklon | last post by:
Hi all, arrays are guaranteed to be contiguous with no padding before or after any array member , but what about enums ..???
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.