Results 1 to 3 of 3

Thread: A customised editor for a component..?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    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:
    1. Public Class DocumentParagraphTextStylesEditor
    2.     Inherits WindowsFormsComponentEditor
    3.  
    4. #Region "Overrides"
    5.     Public Overloads Overrides Function EditComponent( _
    6.                  ByVal context As ITypeDescriptorContext, _
    7.                  ByVal component As Object _
    8.                  ) As Boolean
    9.  
    10.         If Not ((context Is Nothing) OrElse (context.Instance Is Nothing)) Then
    11.             If TypeOf (component) Is TextStyleProvider Then
    12.                 '\\ Show the Form_TextStyleEditor
    13.                 Dim fEdit As New Form_TextStyleEditor
    14.                 If TypeOf (component) Is TextStyleProvider Then
    15.                     fEdit.TextStyles = CType(component, TextStyleProvider).DocumentTextStyles
    16.                     With CType(context.GetService(GetType(IUIService)), IUIService)
    17.                         If .ShowDialog(fEdit) = DialogResult.OK Then
    18.                             CType(component, TextStyleProvider).DocumentTextStyles = fEdit.TextStyles
    19.                             Return True
    20.                         Else
    21.                             Return False
    22.                         End If
    23.  
    24.                     End With
    25.                 End If
    26.             End If
    27.         End If
    28.  
    29.     End Function
    30. #End Region
    31.  
    32. End Class
    ...and I have attached this to the component itself thus:-
    VB Code:
    1. <ToolboxBitmap(GetType(StructuredDocuments.TextStyleProvider), "TextStyleControl.bmp"), _
    2.      EditorAttribute(GetType(StructuredDocuments.DocumentParagraphTextStylesEditor), GetType(WindowsFormsComponentEditor))> _
    3.     Public Class TextStyleProvider
    4.         Inherits System.ComponentModel.Component
    5. '--8<--------------------------------
    6.    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?
    Attached Files Attached Files

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    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...?
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width