2011年5月22日日曜日

How To Use SmartTagPanel In Component Designer when you use VS.NET

Imports System.ComponentModel




_

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

0 件のコメント:

コメントを投稿