Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello, everybody

This is custom property
VB
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
VB
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.
Posted

1 solution

Solved.

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

VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900