Hi Tod,
Thank you for your crystallize explanation.
Question #1
===========
From you response, I'm assuming that I do *not* have to implement IConvertible to get this to work, right?
>>>>>>>>>>>>>>>>>
Yes, You no need to implement the IConvertible interface to work-around this problem. But you need to override the OnSaveChanges method. The attached sample implements the Activator class in the OnSaveChanges override method .Please refer the attached sample and let me know if this helps.
Question #2 and Question #3:
============
I have implemented OnSave() as you describe here following your example. I still get the error that requires implementation of IConvertible. Setting my custom type into the CellValue doesn't seem to resolve the issue. Is is supposed to?
>>>>>>>>>>>>>>>>>
You can use the Activator.CreateInstance method to create new instance of the required base class in OnSaveChanges method. Here is a code snippet that show this task.
protected override bool OnSaveChanges()
{
Type type = this.Grid.Model[this.RowIndex,this.ColIndex].CellValue.GetType();
Type ctype = this.ControlValue.GetType();
if (type == ctype)
return base.OnSaveChanges();
else
{
object objBaseForClass = Activator.CreateInstance(type);
foreach (PropertyInfo propBaseInfo in type.GetProperties())
{
foreach (PropertyInfo propChildInfo in ctype.GetProperties())
{
if (propBaseInfo.Name == propChildInfo.Name)
{
object objPropertyValue = propChildInfo.GetValue(this.ControlValue, null);
if (propBaseInfo.GetSetMethod() != null)
{
propBaseInfo.SetValue(objBaseForClass, objPropertyValue, null);
break;
}
}
}
}
this.Grid.Model[this.RowIndex, this.ColIndex].CellValue = objBaseForClass;
}
return true;
}
Question 4:
============
Do I really need separate "draw" and "edit" cells to hold the representation of my custom cell type? I could see that being useful if they were rendered differently, but they're not. However, all of your examples use separate "draw" and "edit" data members. Can you explain why these are needed?
>>>>>>>>>>>>>
Yes, you will need to have two controls(edit and draw). one for drawing the cell when it is inactive and shared among cells. The other when it is in edit mode.The attached sample have two controls and in the OnDraw method they distinguish between active and inactivate state of the cell.
Please refer to the attached sample for implementation.
http://websamples.syncfusion.com/samples/Grid.Windows/F56622/main.htmBest regards,
Haneef