The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I''m trying to use a GridGroupingControl to edit a collection of objects representing a Name/Value pair.
My underlying object I''ve called SimpleObj, with three properties: Name (String), Type (System.Type), and Value (Object). The intention is that the Type property can help to deserialize the Vale property from a string representation in xml.
I''ve used a GridGroupingControl, added three columns, and bound the control to an ArrayList containing some SimpleObjs in order to add, remove, and edit items.
The problem is is that whenever I edit the Value in the control, it always comes back to the SimpleObj as DbNull.
To keep things as simple as possible I''ve got the following code:
Dim m_al As New ArrayList
Dim obj1 As New SimpleObj
obj1.Name = "Obj1"
obj1.Type = GetType(Single)
obj1.Value = CSng(0)
m_al.Add(obj1)
m_grid.TableDescriptor.Columns.Add("Name")
m_grid.TableDescriptor.Columns.Add("Type")
m_grid.TableDescriptor.Columns.Add("Value")
m_grid.DataSource = m_al
To see what I can do about the problem I''ve tried two things:
1: Just before the call to m_grid.DataSource I add
m_grid.TableDescriptor.Columns("Value").Appearance.AnyCell.CellValueType = GetType(Single)
In other words I''m trying hard coding the CellValueType of the value column, since I''m only adding one item which I know to be of type Single.
This does not work - I still get DbNull, so I''ve no chance of making it work more generally.
2: I''ve tried using a type converter for the Value property. This overrides the CanConvertFrom/To/ConvertFrom/To functions. It attempts to use the ITypeDescriptorContext parameter to create an inner TypeConverter based on the Type of the SimpleObj (available through ITypeDescriptorContext.Instance property), and just call the equivalent functions on that.
The problem with this approah is that (a) the ITypeDescriptorContext is always null so I''ve no way of getting any information about the SimpleObj being converted, and (b) the grid control only seems to call the CanConvertTo function and nothing else.
Does anybody know how to cope with properties of type Object?
Thanks
ADAdministrator Syncfusion Team September 21, 2005 04:02 PM UTC
Hi Eadread,
I think the problem you describe is the same as mentioned in this thread:
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=33637
We fixed that for the 3.3 version. Which version do you use and is it it possible for you to test it with the 3.3 version?
Thanks,
Stefan
>I''m trying to use a GridGroupingControl to edit a collection of objects representing a Name/Value pair.
>
>My underlying object I''ve called SimpleObj, with three properties: Name (String), Type (System.Type), and Value (Object). The intention is that the Type property can help to deserialize the Vale property from a string representation in xml.
>
>I''ve used a GridGroupingControl, added three columns, and bound the control to an ArrayList containing some SimpleObjs in order to add, remove, and edit items.
>
>The problem is is that whenever I edit the Value in the control, it always comes back to the SimpleObj as DbNull.
>
>To keep things as simple as possible I''ve got the following code:
>
>Dim m_al As New ArrayList
>Dim obj1 As New SimpleObj
>obj1.Name = "Obj1"
>obj1.Type = GetType(Single)
>obj1.Value = CSng(0)
>m_al.Add(obj1)
>
>m_grid.TableDescriptor.Columns.Add("Name")
>m_grid.TableDescriptor.Columns.Add("Type")
>m_grid.TableDescriptor.Columns.Add("Value")
>
>m_grid.DataSource = m_al
>
>To see what I can do about the problem I''ve tried two things:
>1: Just before the call to m_grid.DataSource I add
>m_grid.TableDescriptor.Columns("Value").Appearance.AnyCell.CellValueType = GetType(Single)
>
>In other words I''m trying hard coding the CellValueType of the value column, since I''m only adding one item which I know to be of type Single.
>
>This does not work - I still get DbNull, so I''ve no chance of making it work more generally.
>
>2: I''ve tried using a type converter for the Value property. This overrides the CanConvertFrom/To/ConvertFrom/To functions. It attempts to use the ITypeDescriptorContext parameter to create an inner TypeConverter based on the Type of the SimpleObj (available through ITypeDescriptorContext.Instance property), and just call the equivalent functions on that.
>
>The problem with this approah is that (a) the ITypeDescriptorContext is always null so I''ve no way of getting any information about the SimpleObj being converted, and (b) the grid control only seems to call the CanConvertTo function and nothing else.
>
>Does anybody know how to cope with properties of type Object?
>
>Thanks