我从网上下了一段代码学习,不完整,还请帮助看看如何修改,谢谢!!! RRS feed

  • 问题

  • 祝蛇年万事如意!



    Imports System.Drawing.Design
    Imports System.Windows.Forms.Design
    Imports System.ComponentModel

    Public Class UserControl1
        <EditorAttribute(GetType(ColumnsSetupEdit), GetType(System.Drawing.Design.UITypeEditor)), _
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
        MergableProperty(True) _
        > _
        Public Property ColumnsSetup() As ColumnsSetup '定义列设置
                Return _ColumnsSetup
            End Get
            Set(ByVal value As ColumnsSetup)
                _ColumnsSetup = value
            End Set
        End Property
        Private Sub UserControl1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        End Sub
        Public Class ColumnsSetupEdit
            Inherits System.Drawing.Design.UITypeEditor
            Public Overloads Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
                Return UITypeEditorEditStyle.Modal '编辑模式为模式Form,DropDown为下拉列表
            End Function
            Public Overloads Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
                ' Get an IWindowsFormsEditorService.
                Dim editor_service As IWindowsFormsEditorService = _
                    CType(provider.GetService(GetType(IWindowsFormsEditorService)),  _
                ' If we failed to get the editor service, return the value unchanged.
                If editor_service Is Nothing Then Return value
                ' Convert the generic value into a PolyPolyline.
                Dim ppline As ColumnsSetup = DirectCast(value, ColumnsSetup)
                ' Make the editing dialog.
                Dim editor_dialog As New ColumnsSetupFrom '建立自定义的From
                editor_dialog.ColumnsSetup = ppline
                editor_dialog.EditorService = editor_service
                ' Display the editing dialog.
                editor_service.ShowDialog(editor_dialog) '显示Form

                ' Save the new results.
                If editor_dialog.DialogResult = Windows.Forms.DialogResult.OK Then
                    ' Return the new PolyPolyline.
                    context.OnComponentChanged()   '会在InitializeComponent方法里自动加入代码
                    Return editor_dialog.ColumnsSetup '将编辑好的集合返回
                    ' Return the old PolyPolyline.
                    Return ppline
                End If
            End Function
        End Class

    End Class


    2013年2月9日 4:25