将我的自定义属性与绘画事件相关联 [英] Associate my custom property with paint event

查看:45
本文介绍了将我的自定义属性与绘画事件相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

这是自定义属性

hello, everybody

This is custom property

Private BorderColor_ As Color
   Public Property BorderColor() As Color
       Get
           Return BorderColor_
       End Get
       Set(ByVal value As Color)
           BorderColor_ = value
       End Set
   End Property



这是绘画活动



this is paint event

Private Sub SplitCellControl_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim _PenBorder As New Pen(Color.Black, 1)
        _PenBorder.Color = BorderColor
        e.Graphics.DrawRectangle(_PenBorder, 0, 0, MyBase.Width - 1, MyBase.Height - 1)
        _PenBorder.Dispose()
    End Sub



当背景色(自定义)属性更改时,我想触发绘画事件.



I want to fire paint event when backcolor (custom) property change.

推荐答案

已解决.

我已经使用了"Invalidate()"方法来触发绘画事件.

Solved.

I have used ''Invalidate()'' method to fire paint event.

Private BorderColor_ As Color
    Public Property BorderColor() As Color
        Get
            Return BorderColor_
        End Get
        Set(ByVal value As Color)
            BorderColor_ = value
            Invalidate()'Fires paint event.
        End Set
    End Property
 
    Private Sub SplitCellControl_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim _PenBorder As New Pen(Color.Black, 1)
        _PenBorder.Color = BorderColor
        e.Graphics.DrawRectangle(_PenBorder, 0, 0, MyBase.Width - 1, MyBase.Height - 1)
        _PenBorder.Dispose()
    End Sub


这篇关于将我的自定义属性与绘画事件相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆