试着写了一个Control,在里面有一个类,我想在类里面重绘控件Control,但里面Invalidate()和 Refresh都不能用,
类CustomCollectionEditor:
Imports System.Windows.Forms
Imports System.Collections
Imports System.ComponentModel.Design
Public Class CustomCollectionEditor
Inherits System.Drawing.Design.UITypeEditor
Public Delegate Sub CollectionChangedEventHandler(sender As Object, instance As Object, value As Object)
Public Event CollectionChanged As CollectionChangedEventHandler
Private _context As ITypeDescriptorContext
Private edSvc As IWindowsFormsEditorService = Nothing
Public Sub New()
End Sub
Public Overrides Function EditValue(context As ITypeDescriptorContext, provider As IServiceProvider, value As Object) As Object
If context IsNot Nothing AndAlso context.Instance IsNot Nothing AndAlso provider IsNot Nothing Then
Dim originalValue As Object = value
_context = context
edSvc = DirectCast(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
If edSvc IsNot Nothing Then
AddHandler 编辑.ItemAdded, New 编辑.InstanceEventHandler(AddressOf ItemAdded)
AddHandler 编辑.ItemRemoved, New 编辑.InstanceEventHandler(AddressOf ItemRemoved)
编辑.newval = value
编辑.pg_PropGrid.SelectedObject = Nothing
编辑.Collection = DirectCast(value, System.Collections.CollectionBase)
context.OnComponentChanging()
If edSvc.ShowDialog(编辑) = DialogResult.OK Then
OnCollectionChanged(context.Instance, value)
context.OnComponentChanged()
'我想在这里重绘控件Control(),求教该如何让做,谢谢!!!
End If
End If
End If
Return value
End Function