Home All Groups Group Topic Archive Search About

Referencing object of same name

Author
26 Jun 2009 3:40 AM
tsluu
public class form1

Private WithEvents Appt As Calendar.Apptmnt

Private Sub Panel2_MouseDoubleClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseDoubleClick
static idx as integer
Appt = New Calendar.Apptmnt
Appt.Name = idx
idx = idx + 1

Panel2.Controls.Add(Appt)

AddHandler Appt.MouseUp, AddressOf Appt_myMouseUp
AddHandler Appt.MouseDown, AddressOf Appt_myMouseDown
AddHandler Appt.MouseMove, AddressOf Appt_myMouseMove
End Sub

Based on the above code, how do I refer to individual Appt when I want to
reference them during mouse_move event. I know how to reference the current
one I clicked, that is by using DirectCast in the event. But how about the
ones that are not in focus.

Author
26 Jun 2009 7:29 AM
Cor Ligthert[MVP]
You have made it private on global level of your class, therefore appt is
accessible in your complete class.


Show quoteHide quote
"tsluu" <ts***@discussions.microsoft.com> wrote in message
news:72FD405A-BCF8-4C58-8BEB-5CC120DF439E@microsoft.com...
> public class form1
>
> Private WithEvents Appt As Calendar.Apptmnt
>
> Private Sub Panel2_MouseDoubleClick(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseDoubleClick
> static idx as integer
> Appt = New Calendar.Apptmnt
> Appt.Name = idx
> idx = idx + 1
>
> Panel2.Controls.Add(Appt)
>
> AddHandler Appt.MouseUp, AddressOf Appt_myMouseUp
> AddHandler Appt.MouseDown, AddressOf Appt_myMouseDown
> AddHandler Appt.MouseMove, AddressOf Appt_myMouseMove
> End Sub
>
> Based on the above code, how do I refer to individual Appt when I want to
> reference them during mouse_move event. I know how to reference the
> current
> one I clicked, that is by using DirectCast in the event. But how about the
> ones that are not in focus.