D
danieljroot
I'm writing a CompositeControl that includes a child GridView. I want
to expose the GridView's Columns property at design time and allow the
developer to customize the columns, but don't want them to set the
DataSourceID, etc. So, I did this on my control:
<PersistenceMode(PersistenceMode.InnerProperty), _
Editor(GetType(System.Web.UI.Design.WebControls.DataControlFieldTypeEditor),
GetType(UITypeEditor)), _
MergableProperty(False), _
DefaultValue(CStr(Nothing)), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
_
Public ReadOnly Property Columns() As
DataControlFieldCollection
Get
Me.EnsureChildControls()
Return memberGridView.Columns
End Get
End Property
However, the DataControlFieldTypeEditor does not appear when the [...]
button is clicked in the property grid. No UI or error occurs at all.
Using Reflector, I suspect that this is because the control is not a
DataBoundControl:
Public Overrides Function EditValue(ByVal context As
ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value
As Object) As Object
Dim control1 As DataBoundControl =
TryCast(context.Instance,DataBoundControl)
If (control1 Is Nothing) Then
Return Nothing
End If
....
But I'm stuck there. So, my question is: How can I expose a Columns
property and get the design-time behavior identical to the GridView?
to expose the GridView's Columns property at design time and allow the
developer to customize the columns, but don't want them to set the
DataSourceID, etc. So, I did this on my control:
<PersistenceMode(PersistenceMode.InnerProperty), _
Editor(GetType(System.Web.UI.Design.WebControls.DataControlFieldTypeEditor),
GetType(UITypeEditor)), _
MergableProperty(False), _
DefaultValue(CStr(Nothing)), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
_
Public ReadOnly Property Columns() As
DataControlFieldCollection
Get
Me.EnsureChildControls()
Return memberGridView.Columns
End Get
End Property
However, the DataControlFieldTypeEditor does not appear when the [...]
button is clicked in the property grid. No UI or error occurs at all.
Using Reflector, I suspect that this is because the control is not a
DataBoundControl:
Public Overrides Function EditValue(ByVal context As
ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value
As Object) As Object
Dim control1 As DataBoundControl =
TryCast(context.Instance,DataBoundControl)
If (control1 Is Nothing) Then
Return Nothing
End If
....
But I'm stuck there. So, my question is: How can I expose a Columns
property and get the design-time behavior identical to the GridView?