Event's & Methods

Joined
Oct 2, 2007
Messages
14
Programming Experience
1-3
Hi all, im having issues with event's and methods.

I have 2 forms, for example form1 and form 2. on form 1 i have a label and on form 2 i have a check box. what im trying to achieve is when the check box is checked in form 2, for the label1.visible=false to be called, im looking for an explanation so that i can better further my knowledge with vb.Net.

Thanks in advance

domino.vbcoder
 
Hi there,

I had a play and came up with this not great but it is a start.

FORM 1 Code

Public Class Form1
Dim plabelvisible As Boolean

Public Property labelvisible()
Get
Return plabelvisible
End Get
Set(ByVal value)
plabelvisible = value
End Set
End Property

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If Me.plabelvisible = False Then
Me.Label1.Visible = False
Else
Me.Label1.Visible = True
End If
End Sub
End Class

Form 2 Code

Public Class Form2
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
Dim frm1 As Form1 = Form1
frm1.labelvisible = Me.CheckBox1.Checked
frm1.Refresh()
End Sub
End Class

Hope this helps.

Alex
 
Unfortunately not

Thank you for your reply but the way to go about it is using handles and deligates as raising an event for the proc and deligate class gets very messy
and can lead to many many errors.

But thank you for your reply its much appretiated

Domino.VBcoder

:)
 
Back
Top