• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

VB.NET ControlDesigner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中System.Web.UI.Design.ControlDesigner的典型用法代码示例。如果您正苦于以下问题:VB.NET ControlDesigner类的具体用法?VB.NET ControlDesigner怎么用?VB.NET ControlDesigner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ControlDesigner类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1: New

' 导入命名空间
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.ComponentModel.Design

Namespace ASPNet.Design.Samples.VB

    ' Simple text Web control renders a text string.
    ' This control is associated with the TextSizeWebControlDesigner.
    <DesignerAttribute(GetType(TextSizeWebControlDesigner)), _
        ToolboxData("<{0}:TextControl runat='server'></{0}:TextControl>")> _
    Public Class TextControl
        Inherits Label

        Private _largeText As Boolean = True

        ' Constructor
        Public Sub New()
            Text = "Test Phrase"
            SetSize()
        End Sub

        ' Determines whether the text is large or small
        <Bindable(True), Category("Appearance"), DefaultValue(True)> _
        Public Property LargeText() As Boolean
            Get
                Return _largeText
            End Get
            Set(ByVal value As Boolean)
                _largeText = value
                SetSize()
            End Set
        End Property

        ' Applies the LargeText property to the control
        Private Sub SetSize()
            If LargeText Then
                Me.Font.Size = FontUnit.XLarge
            Else
                Me.Font.Size = FontUnit.Small
            End If
        End Sub
    End Class


    ' This control designer offers DesignerActionList commands
    ' that can alter the design time html of the associated control.
    Public Class TextSizeWebControlDesigner
        Inherits ControlDesigner

        Private _actionLists As DesignerActionListCollection

        ' Do not allow direct resizing of the control
        Public Overrides ReadOnly Property AllowResize() As Boolean
            Get
                Return False
            End Get
        End Property

        ' Return a custom ActionList collection
        Public Overrides ReadOnly Property ActionLists() As System.ComponentModel.Design.DesignerActionListCollection
            Get
                If IsNothing(_actionLists) Then
                    _actionLists = New DesignerActionListCollection()
                    _actionLists.AddRange(MyBase.ActionLists)

                    ' Add a custom DesignerActionList
                    _actionLists.Add(New ActionList(Me))
                End If

                Return _actionLists
            End Get
        End Property

        ' Create a custom class of DesignerActionList
        Public Class ActionList
            Inherits DesignerActionList
            Private _parent As TextSizeWebControlDesigner
            Private _items As DesignerActionItemCollection

            ' Constructor
            Public Sub New(ByRef parent As TextSizeWebControlDesigner)
                MyBase.New(parent.Component)
                _parent = parent
            End Sub

            ' Create the ActionItem collection and add one command
            Public Overrides Function GetSortedActionItems() As DesignerActionItemCollection
                If IsNothing(_items) Then
                    _items = New DesignerActionItemCollection()
                    _items.Add(New DesignerActionMethodItem(Me, "ToggleLargeText", "Toggle Text Size", True))
                End If

                Return _items
            End Function

            ' ActionList command to change the text size
            Private Sub ToggleLargeText()
                ' Get a reference to the parent designer's associated control
                Dim ctl As TextControl = CType(_parent.Component, TextControl)

                ' Get a reference to the control's LargeText property
                Dim propDesc As PropertyDescriptor = TypeDescriptor.GetProperties(ctl)("LargeText")

                ' Get the current value of the property
                Dim v As Boolean = CType(propDesc.GetValue(ctl), Boolean)
                ' Toggle the property value
                propDesc.SetValue(ctl, (Not v))
            End Sub
        End Class
    End Class
End Namespace
开发者ID:VB.NET开发者,项目名称:System.Web.UI.Design,代码行数:114,代码来源:ControlDesigner



注:本文中的System.Web.UI.Design.ControlDesigner类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET EmptyControlCollection类代码示例发布时间:2022-05-24
下一篇:
VB.NET Port类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap