vb.net:当变量改变时重绘

时间:2014-04-18 07:29:38

标签: vb.net events repaint

我在这里设计了一个圆圈:

Private Sub HeatmapBande_Paint(sender As Object, e As ystem.Windows.Forms.PaintEventArgs)  Handles Me.Paint  
'draw a circle here  
End Sub

圆圈有一个半径(rayonZoneElectrodeEnCases):

Public Property ProRayonZoneElectrodeEnCases() As Integer
    Get  
        Return rayonZoneElectrodeEnCases  
    End Get  
    Set(value As Integer)  
        rayonZoneElectrodeEnCases = value
        'reapint but how?????
    End Set  
End Property

我需要的是:当我们调用Property来改变半径时:MyClass.ProRayonZoneElectrodeEnCases = 10,圆圈将被重新绘制

我不知道该怎么做,你能帮助我吗?

事先提前

1 个答案:

答案 0 :(得分:1)

如果使用Form的paint事件来执行绘图,则将Me.Invalidate()添加到属性的set方法

Public Property ProRayonZoneElectrodeEnCases() As Integer
Get  
    Return rayonZoneElectrodeEnCases  
End Get  
Set(value As Integer)  
    rayonZoneElectrodeEnCases = value
    Me.Invalidate()
End Set  
End Property

这会强制表单刷新自己。 见这里:http://msdn.microsoft.com/en-us/library/system.windows.forms.control.invalidate%28v=vs.100%29.aspx