Need some guidance on a databinding issue.
I need to create an object that "looks like double" to a datagrid.
I think it's easiest to describe with an example:
First we have the custom object that I want to make look like a double from a databinding perspective.
Public Class MyDouble
Dim _value As Double
Public Sub New(ByVal value As Double)
_value = value
End Sub
Public Property Value() As Double
'this is the property I want to bind
Get
Return _value
End Get
Set(ByVal Value As Double)
_value = Value
End Set
End Property
Public Property AlternateValue() As Double
'this is an example of some other property I don't want to bind
Get
Return _value * 2
End Get
Set(ByVal Value As Double)
_value = Value / 2
End Set
End Property
End Class
Second we have an object that has two properties, one that is of type MyDouble, and another that is a Double.
When I bind a collection of these to a datagrid I want the grid to see it as two doubles.
When I access the properties via code I want to see MyOwnDouble as MyDouble.
Public Class MyObject
Private _MyOwnDouble As MyDouble
Private _MyRealDouble As Double
Public Property MyOwnDouble() As MyDouble
Get
Return _MyOwnDouble
End Get
Set(ByVal Value As MyDouble)
_MyOwnDouble = Value
End Set
End Property
Public Property MyRealDouble() As Double
Get
Return _MyRealDouble
End Get
Set(ByVal Value As Double)
_MyRealDouble = Value
End Set
End Property
End Class
I've considered adding an additonal property in the object that exposes the Value property of MyOwnDouble, but I'd rather avoid that.
Public Property MyOwnDoubleValue() As Double
Get
Return _MyOwnDouble.Value
End Get
Set(ByVal Value As MyDouble)
_MyOwnDouble.Value = Value
End Set
End Property
I've been trying to implement ITypedList and ICustomTypeDescriptor to no avail.
I'm not sure if I'm on the right path, any ideas?
Thanks,
Chris Wardell
I need to create an object that "looks like double" to a datagrid.
I think it's easiest to describe with an example:
First we have the custom object that I want to make look like a double from a databinding perspective.
Public Class MyDouble
Dim _value As Double
Public Sub New(ByVal value As Double)
_value = value
End Sub
Public Property Value() As Double
'this is the property I want to bind
Get
Return _value
End Get
Set(ByVal Value As Double)
_value = Value
End Set
End Property
Public Property AlternateValue() As Double
'this is an example of some other property I don't want to bind
Get
Return _value * 2
End Get
Set(ByVal Value As Double)
_value = Value / 2
End Set
End Property
End Class
Second we have an object that has two properties, one that is of type MyDouble, and another that is a Double.
When I bind a collection of these to a datagrid I want the grid to see it as two doubles.
When I access the properties via code I want to see MyOwnDouble as MyDouble.
Public Class MyObject
Private _MyOwnDouble As MyDouble
Private _MyRealDouble As Double
Public Property MyOwnDouble() As MyDouble
Get
Return _MyOwnDouble
End Get
Set(ByVal Value As MyDouble)
_MyOwnDouble = Value
End Set
End Property
Public Property MyRealDouble() As Double
Get
Return _MyRealDouble
End Get
Set(ByVal Value As Double)
_MyRealDouble = Value
End Set
End Property
End Class
I've considered adding an additonal property in the object that exposes the Value property of MyOwnDouble, but I'd rather avoid that.
Public Property MyOwnDoubleValue() As Double
Get
Return _MyOwnDouble.Value
End Get
Set(ByVal Value As MyDouble)
_MyOwnDouble.Value = Value
End Set
End Property
I've been trying to implement ITypedList and ICustomTypeDescriptor to no avail.
I'm not sure if I'm on the right path, any ideas?
Thanks,
Chris Wardell