Skip to main content
Email Password   helpLost your password?

Introduction

This article provides a base class that helps developers build customized design-time extensions for components and controls through Smart Tag designer panels.

How to Use this Helper (Base) Class

You can easily define your custom Smart Tag panels containing your action list items (Properties, Methods (Verbs), and Texts). Here is a sample control which derives from the TextBox control and uses a custom designer (mySmartTagActionList). The items are added in the AddActionItems() method. Any property or method you want to add should be defined in your SmartTagActionList class which is derived from the SmartTagActionListBase class.

Here are the required steps to create your custom control designer:

The Sample Code

Here is a sample control which uses a custom SmartTagPanel Designer:

Imports System.ComponentModel

<Designer(GetType(SmartTagControlDesigner(Of mySmartTagActionList)))> _
Public Class XTextBox
    Inherits TextBox

    '... customizations


End Class

Public Class mySmartTagActionList
    Inherits SmartTagActionListBase

    Private m_Control As XTextBox

    Sub New(ByVal component As IComponent)
        MyBase.New(component)
        m_Control = CType(component, XTextBox)
    End Sub

    Public Property BackColor() As Color
        Get
            Return m_Control.BackColor
        End Get
        Set(ByVal value As Color)
            Me.SetPropertyByName(m_Control, "BackColor", value)
        End Set
    End Property

    Public Property ForeColor() As Color
        Get
            Return m_Control.ForeColor
        End Get
        Set(ByVal value As Color)
            Me.SetPropertyByName(m_Control, "ForeColor", value)
        End Set
    End Property

    Public Property IsMultiline() As Boolean
        Get
            Return m_Control.Multiline
        End Get
        Set(ByVal value As Boolean)
            Me.SetPropertyByName(m_Control, "Multiline", value)
        End Set
    End Property

    Public Sub SwapColors()
        Dim c As Color = Me.ForeColor
        Me.ForeColor = Me.BackColor
        Me.BackColor = c
        RefreshDesigner()
    End Sub

    Public Overrides Sub AddActionItems()
        'These properties are already defined 
        'in base (SmartTagActionListBase) class:

        '  => Name, Text, Font, RightToLeft

        'Other properties/Methods should be defined in current class

        AddActionHeader("Main")
        AddActionProperty("Name", "Name:", "Main", "")
        AddActionProperty("Text", "Text:", "Main", "")
        AddActionProperty("Font", "Font:", "Main", "")
        AddActionProperty("IsMultiline", "Multiline:", "", "")
        AddActionHeader("Colors")
        AddActionProperty("ForeColor", "ForeColor:", _
                          "Colors", "Sets the ForeColor")
        AddActionProperty("BackColor", "BackColor:", _
                          "Colors", "Sets the BackColor")
        AddActionText("This is my info...", "Colors")
        AddActionMethod("SwapColors", "Swap Colors", _
                        "Colors", "Swap ForeColor/BackColor", True)
    End Sub

End Class

Notes

You may see this article: Creating Property Editors in Design Time for VS.NET Easily (UITypeEditor Helper), to create UITypeEditor's easily. An 'Editor' is related to a property, but a 'Designer' is related to a control or component (a class)! By means of UITypeEditors, you can provide a custom editor window (e.g., a dropdown window) to edit each property of a control. You may mix both of the 'Designer' and 'Editor' attributes to achieve better design-time extensions for components and controls.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralSmart Tag crashes with Swap Colors Pin
Derek Hart
6:59 2 Mar '09  
GeneralWhere can I create my own error? Pin
Derek Hart
6:56 2 Mar '09  
General'SmartMoveTag' from Panel Inhereted control disapears. Pin
magiel_van_gaalen
0:23 8 Sep '08  
AnswerRe: 'SmartMoveTag' from Panel Inhereted control disapears. Pin
Member 2046625
13:57 26 Nov '08  
GeneralC# Pin
sabrown100
11:53 18 Oct '07  
QuestionCreate composite controls Pin
bmwgamil
14:09 9 Aug '07  
QuestionHow to add smart tag to Custom Control inherited from ComboBox Pin
Kristipati Subramanyam
20:04 3 Aug '07  
GeneralCustom UITypeEditor on ActionList Pin
DevDiver
6:26 22 Jan '07  
GeneralRe: Custom UITypeEditor on ActionList Pin
S.Serpooshan
7:27 22 Jan '07  
GeneralRe: Custom UITypeEditor on ActionList Pin
DevDiver
7:55 22 Jan '07  
GeneralAutoExpand Pin
Henrique Carvalho
23:36 21 Jan '07  
GeneralRe: AutoExpand [modified] Pin
S.Serpooshan
5:06 22 Jan '07  
GeneralRe: AutoExpand Pin
Henrique Carvalho
6:09 22 Jan '07  
GeneralThank you Pin
babakzawari
21:31 18 Jan '07  
GeneralRe: Thank you Pin
S.Serpooshan
7:00 19 Jan '07  
Generalsolved Pin
Saadz
11:56 14 Jan '07  
Generalhelps me alot, thanks Pin
ahmed45
2:19 13 Jan '07  


Last Updated 22 Jan 2007 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009