祝蛇年万事如意,我从网上下了一段代码学习,不完整,还请帮助看看如何修改,谢谢!!!
我是从http://blog.sina.com.cn/s/blog_591f16290100ge3l看到的。
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 '定义列设置
Get
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)), _
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