當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET DetailsViewDesigner類代碼示例

本文整理匯總了VB.NET中System.Web.UI.Design.WebControls.DetailsViewDesigner的典型用法代碼示例。如果您正苦於以下問題:VB.NET DetailsViewDesigner類的具體用法?VB.NET DetailsViewDesigner怎麽用?VB.NET DetailsViewDesigner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DetailsViewDesigner類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: PreFilterProperties

' 導入命名空間
Imports System.Web
Imports System.Drawing
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.Collections
Imports System.ComponentModel
Imports System.Security.Permissions

Namespace Examples.VB.WebControls.Design

    ' The MyDetailsView is a copy of the DetailsView.
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <Designer(GetType(Examples.VB.WebControls.Design.MyDetailsViewDesigner))> _
    Public Class MyDetailsView
        Inherits DetailsView
    End Class

    ' Override members of the DetailsViewDesigner.
    <ReflectionPermission(SecurityAction.Demand, Flags:=ReflectionPermissionFlag.MemberAccess)> _
    Public Class MyDetailsViewDesigner
        Inherits DetailsViewDesigner

        ' Determines the number of page links in the pager row
        ' when viewed in the designer.
        Protected Overrides ReadOnly Property SampleRowCount() As Integer
            Get
                ' Render five page links in the pager row.
                Return 5
            End Get
        End Property ' SampleRowCount

        ' Shadow the control properties with design-time properties.
        Protected Overrides Sub PreFilterProperties( _
            ByVal properties As IDictionary)

            ' Call the base method first.
            MyBase.PreFilterProperties(properties)

            ' Make the NamingContainer visible in the Properties grid.
            Dim selectProp As PropertyDescriptor = _
                CType(properties("NamingContainer"), PropertyDescriptor)
            properties("NamingContainer") = _
                TypeDescriptor.CreateProperty(selectProp.ComponentType, _
                    selectProp, BrowsableAttribute.Yes)
        End Sub

        ' Generate the design-time markup.
        Private Const capTag As String = "caption"
        Private Const trOpen As String = "tr><td colspan=2 align=center"
        Private Const trClose As String = "td></tr"

        Public Overrides Function GetDesignTimeHtml() As String

            ' Make the full extent of the control more visible in the designer.
            ' If the border style is None or NotSet, change the border to
            ' a wide, blue, dashed line. Include the caption within the border.
            Dim myDV As MyDetailsView = CType(Component, MyDetailsView)
            Dim markup As String = Nothing
            Dim charX As Integer

            ' Check if the border style should be changed.
            If (myDV.BorderStyle = BorderStyle.NotSet Or _
                myDV.BorderStyle = BorderStyle.None) Then

                Dim oldBorderStyle As BorderStyle = myDV.BorderStyle
                Dim oldBorderWidth As Unit = myDV.BorderWidth
                Dim oldBorderColor As Color = myDV.BorderColor

                ' Set design-time properties and catch any exceptions.
                Try
                    myDV.BorderStyle = BorderStyle.Dashed
                    myDV.BorderWidth = Unit.Pixel(3)
                    myDV.BorderColor = Color.Blue

                    ' Call the base method to generate the markup.
                    markup = MyBase.GetDesignTimeHtml()

                Catch ex As Exception
                    markup = GetErrorDesignTimeHtml(ex)

                Finally
                    ' Restore the properties to their original settings.
                    myDV.BorderStyle = oldBorderStyle
                    myDV.BorderWidth = oldBorderWidth
                    myDV.BorderColor = oldBorderColor
                End Try

            Else
                ' Call the base method to generate the markup.
                markup = MyBase.GetDesignTimeHtml()
            End If

            ' Look for a <caption> tag.
            charX = markup.IndexOf(capTag)
            If charX > 0 Then

                ' Replace the first caption with 
                ' "tr><td colspan=2 align=center".
                markup = markup.Remove(charX, _
                    capTag.Length).Insert(charX, trOpen)

                ' Replace the second caption with "td></tr".
                charX = markup.IndexOf(capTag, charX)
                If charX > 0 Then
                    markup = markup.Remove(charX, _
                        capTag.Length).Insert(charX, trClose)
                End If
            End If

            Return markup

        End Function ' GetDesignTimeHtml
    End Class
End Namespace ' Examples.VB.WebControls.Design
開發者ID:VB.NET開發者,項目名稱:System.Web.UI.Design.WebControls,代碼行數:118,代碼來源:DetailsViewDesigner


注:本文中的System.Web.UI.Design.WebControls.DetailsViewDesigner類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。