A
--== Alain ==--
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(values[0]);
GridLine.Style =
(GridLineStyle)StringConverter.ConvertFromString(values[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);
}
}
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(values[0]);
GridLine.Style =
(GridLineStyle)StringConverter.ConvertFromString(values[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);
}
}