1 Attachment(s)
A customised editor for a component..?
OK - I am building a couple of windows forms components, one which provides text styles (like the header/subheader/ etc. stuff in MS Word) and another which allows you to build structured print documents....
However I am not able to attach the component designer to the component.
(full code attached)
So - I have a class that inherits from WindowsFormsComponentEditor:
VB Code:
Public Class DocumentParagraphTextStylesEditor
Inherits WindowsFormsComponentEditor
#Region "Overrides"
Public Overloads Overrides Function EditComponent( _
ByVal context As ITypeDescriptorContext, _
ByVal component As Object _
) As Boolean
If Not ((context Is Nothing) OrElse (context.Instance Is Nothing)) Then
If TypeOf (component) Is TextStyleProvider Then
'\\ Show the Form_TextStyleEditor
Dim fEdit As New Form_TextStyleEditor
If TypeOf (component) Is TextStyleProvider Then
fEdit.TextStyles = CType(component, TextStyleProvider).DocumentTextStyles
With CType(context.GetService(GetType(IUIService)), IUIService)
If .ShowDialog(fEdit) = DialogResult.OK Then
CType(component, TextStyleProvider).DocumentTextStyles = fEdit.TextStyles
Return True
Else
Return False
End If
End With
End If
End If
End If
End Function
#End Region
End Class
...and I have attached this to the component itself thus:-
VB Code:
<ToolboxBitmap(GetType(StructuredDocuments.TextStyleProvider), "TextStyleControl.bmp"), _
EditorAttribute(GetType(StructuredDocuments.DocumentParagraphTextStylesEditor), GetType(WindowsFormsComponentEditor))> _
Public Class TextStyleProvider
Inherits System.ComponentModel.Component
'--8<--------------------------------
End Class
However nothing happens - the component still tries to use the standard collection editor (with ghastly results).
Any ideas? or pointer to working code sample?
Re: A customised editor for a component..?
Are you having the problem at run time or design time where it's not showing the editor correctly?
1 Attachment(s)
Re: A customised editor for a component..?
At design time.
Add a "TextStyleProvider" component to a form and select properties. Then press the button next to the property "DocumentTextStyles" and you should get a nice designer (like shown) but instead a default collection editing window comes up...?