Problem with custom server control

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
I'm utterly frustrated and could really use some help. I'm making a custom user control that basically is a datagrid that allows frozen columns. To set the columns that will be frozen I've created a custom editor. The editor itself works great and changes persist in memory, however no html code is written even though I'm using the PersistenceMode(PersistenceMode.InnerProperty) attribute. So whenever the project is built any additions to the 'FrozenColumns' property are lost. It has to be something in my designer because if I change my Editor attribute to something else code is generated (you can see the following in HTML view:
<FrozenColumns>
</FrozenColumns>
).

I would use something else since it obviously writes the code but it isn't feasible for this project, the above was just how I determined it was my custom editor causing the problem. Here is the code for my Editor. Does anyone see any problems? The property that is being set is called FrozenColumns and derives from CollectionBase. Sorry it's not 'pretty' formatted. My work computer doesn't support the WYSIWYG editor here at work (security has javascript turned off).

Public Class FreezableDataGridEditor
Inherits System.Drawing.Design.UITypeEditor

Public Overloads Overrides Function EditValue(ByVal context As ComponentModel.ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value As Object) As Object
Dim service As IWindowsFormsEditorService
Dim instance, orgInstance As FreezableDataGrid

If Not context Is Nothing AndAlso Not context.Instance Is Nothing AndAlso Not provider Is Nothing Then
'Research to understand this
service = DirectCast(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
If Not service Is Nothing Then
instance = DirectCast(context.Instance, FreezableDataGrid)
EditorForm.Execute(instance)
context.PropertyDescriptor.SetValue(context.Instance, instance.FrozenColumns)
End If
End If

Return instance.FrozenColumns

End Function

Public Overloads Overrides Function GetEditStyle(ByVal context As ComponentModel.ITypeDescriptorContext) As Drawing.Design.UITypeEditorEditStyle

If Not context Is Nothing AndAlso Not context.Instance Is Nothing Then
Return UITypeEditorEditStyle.Modal
Else
Return MyBase.GetEditStyle(context)
End If

End Function

End Class


Here is the property in with the attributes:

<Browsable(True), Category("Appearance"), Editor(GetType(FreezableDataGridEditor), GetType(System.Drawing.Design.UITypeEditor)), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)> _
Public ReadOnly Property FrozenColumns() As FreezableDataGridColumnCollection
Get
If _frozenColumns Is Nothing Then
_frozenColumns = New FreezableDataGridColumnCollection
End If
Return _frozenColumns
End Get
End Property

Thanks in advance for any help... in desperate need of some.
 
Back
Top