本文整理匯總了VB.NET中System.ComponentModel.Design.IDesigner接口的典型用法代碼示例。如果您正苦於以下問題:VB.NET IDesigner接口的具體用法?VB.NET IDesigner怎麽用?VB.NET IDesigner使用的例子?那麽, 這裏精選的接口代碼示例或許可以為您提供幫助。
在下文中一共展示了IDesigner接口的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: TestControl
' 導入命名空間
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms
' A DesignerAttribute associates the example IDesigner with an example control.
<DesignerAttribute(GetType(ExampleIDesigner))> _
Public Class TestControl
Inherits System.Windows.Forms.UserControl
Public Sub New()
End Sub
End Class
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class ExampleIDesigner
Implements System.ComponentModel.Design.IDesigner
' Local reference to the designer's component.
Private _component As IComponent
' Public accessor to the designer's component.
Public ReadOnly Property Component() As System.ComponentModel.IComponent Implements IDesigner.Component
Get
Return _component
End Get
End Property
Public Sub New()
End Sub
Public Sub Initialize(ByVal component As System.ComponentModel.IComponent) Implements IDesigner.Initialize
' This method is called after a designer for a component is created,
' and stores a reference to the designer's component.
Me._component = component
End Sub
' This method peforms the 'default' action for the designer. The default action
' for a basic IDesigner implementation is invoked when the designer's component
' is double-clicked. By default, a component associated with a basic IDesigner
' implementation is displayed in the design-mode component tray.
Public Sub DoDefaultAction() Implements IDesigner.DoDefaultAction
' Shows a message box indicating that the default action for the designer was invoked.
MessageBox.Show("The DoDefaultAction method of an IDesigner implementation was invoked.", "Information")
End Sub
' Returns a collection of designer verb menu items to show in the
' shortcut menu for the designer's component.
Public ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Implements IDesigner.Verbs
Get
Dim verbs_ As New DesignerVerbCollection()
Dim dv1 As New DesignerVerb("Display Component Name", New EventHandler(AddressOf Me.ShowComponentName))
verbs_.Add(dv1)
Return verbs_
End Get
End Property
' Event handler for displaying a message box showing the designer's component's name.
Private Sub ShowComponentName(ByVal sender As Object, ByVal e As EventArgs)
If (Me.Component IsNot Nothing) Then
MessageBox.Show(Me.Component.Site.Name, "Designer Component's Name")
End If
End Sub
' Provides an opportunity to release resources before object destruction.
Public Sub Dispose() Implements IDisposable.Dispose
End Sub
End Class