By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,009 Members | 2,866 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,009 IT Pros & Developers. It's quick & easy.

issue in property window

P: n/a
Hi,

I've created a simple class "GridLines" having 3 properties (Prop1,
Prop2, and Prop3).

in my custom control, i've created a property based on this class
"GridLines".

To show the GridLines properties as my custom control subproperties, i
used an expandable ExpandableObjectConverter class for my GridLineConverter.

therefore in my custom control property window, i have the following thing :

GridLines = Prop1_value, Prop2_value, Prop3_value
- Prop1 : value
- Prop2 : value
- Prop3 : value

Everything works well if i use my custom control subproperties (Prop1,
Prop2, Prop3) to setup the GridLine property (BTW, GridLine property
value is a string).

However, if i type directly to GridLine property field "Prop1_value,
Prop2_Value, Prop3_value", my component raises an error message. I've
checked several times my code, but i must be blind because o do not see
any error.

here is the piece of code which raises the error :

public CGridLine ConvertFromString(object value)
{
string[] values = ((string)value).Split(',');
if (values.Length != 3)
throw new ArgumentException("Could not convert the value !");
try
{
CGridLine GridLine = new CGridLine();
ColorConverter ColorConverter = new ColorConverter();
StringConverter StringConverter = new StringConverter();

GridLine.Lines =
(GridLines)StringConverter.ConvertFromString(value s[0]);
GridLine.Style =
(GridLineStyle)StringConverter.ConvertFromString(v alues[1]);
GridLine.Color =
(Color)ColorConverter.ConvertFromString(values[2]);

// Convert the name of the enumerated value into the corresponding
// enumerated value (which is actually an integer constant).

return GridLine;
}
catch (Exception err)
{
throw new ArgumentException("Could not convert the value \n\n
Error Message : " + err.Message);
}
}
-----------------
thanks for help.

AL.
Feb 10 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Guys,

i found the problem.
Prop1 and Prop2 are enum types, therefore i had to use :
my_GridLine.Style = (GridLineStyle)Enum.Parse(typeof(GridLineStyle),
values[1], true);

instead of :
GridLine.Style =
(GridLineStyle)StringConverter.ConvertFromString(v alues[1]);
Al.

--== Alain ==-- wrote:
Hi,

I've created a simple class "GridLines" having 3 properties (Prop1,
Prop2, and Prop3).

in my custom control, i've created a property based on this class
"GridLines".

To show the GridLines properties as my custom control subproperties, i
used an expandable ExpandableObjectConverter class for my
GridLineConverter.

therefore in my custom control property window, i have the following
thing :

GridLines = Prop1_value, Prop2_value, Prop3_value
- Prop1 : value
- Prop2 : value
- Prop3 : value

Everything works well if i use my custom control subproperties (Prop1,
Prop2, Prop3) to setup the GridLine property (BTW, GridLine property
value is a string).

However, if i type directly to GridLine property field "Prop1_value,
Prop2_Value, Prop3_value", my component raises an error message. I've
checked several times my code, but i must be blind because o do not see
any error.

here is the piece of code which raises the error :

public CGridLine ConvertFromString(object value)
{
string[] values = ((string)value).Split(',');
if (values.Length != 3)
throw new ArgumentException("Could not convert the value !");
try
{
CGridLine GridLine = new CGridLine();
ColorConverter ColorConverter = new ColorConverter();
StringConverter StringConverter = new StringConverter();

GridLine.Lines =
(GridLines)StringConverter.ConvertFromString(value s[0]);
GridLine.Style =
(GridLineStyle)StringConverter.ConvertFromString(v alues[1]);
GridLine.Color =
(Color)ColorConverter.ConvertFromString(values[2]);

// Convert the name of the enumerated value into the corresponding
// enumerated value (which is actually an integer constant).

return GridLine;
}
catch (Exception err)
{
throw new ArgumentException("Could not convert the value \n\n
Error Message : " + err.Message);
}
}
-----------------
thanks for help.

AL.
Feb 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.