自定义控件强制重绘,请教版主,谢谢!!! RRS feed

  • 问题

  • 试着写了一个Control,在里面有一个类,我想在类里面重绘控件Control,但里面Invalidate()和   Refresh都不能用,


    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)
                    If edSvc.ShowDialog(编辑) = DialogResult.OK Then
                        OnCollectionChanged(context.Instance, value)
                    End If
                End If
            End If
            Return value
        End Function

    2015年3月15日 3:29


  • 你要刷新的是不是这个Editor 所用到的控件?

    remember make the reply as answer and vote the reply as helpful if it helps.

    • 已标记为答案 YQY888 2015年3月29日 5:32
    2015年3月17日 4:35