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:
...and I have attached this to the component itself thus:-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
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?


Reply With Quote
