N
Nathan Carroll
Instead of impementing icomparer for a custom calendar class to find a
button
with a particular date property value I have done the following:
'on a form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim b As calBut = Me.Calendar1.CallButton(#10/8/2004#)
Console.WriteLine(b.Date)
End Sub
'the calendar control
Public Class Calendar
Inherits System.Windows.Forms.UserControl
'......
Public Event CallingButton(ByVal d As Date)
Public calledbutton As calBut
Function CallButton(ByVal d As Date) As calBut
calledbutton = Nothing
RaiseEvent CallingButton(d)
Return calledbutton
End Function
End Class
'calendar button class
Public Class calBut
Inherits Button
'......
Friend Sub OnCallingButton(ByVal d As Date)
If d = Me.Date Then
Dim parent As Calendar = DirectCast(Me.Parent, Calendar)
parent.calledbutton = Me
End If
End Sub
End Class
button
with a particular date property value I have done the following:
'on a form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim b As calBut = Me.Calendar1.CallButton(#10/8/2004#)
Console.WriteLine(b.Date)
End Sub
'the calendar control
Public Class Calendar
Inherits System.Windows.Forms.UserControl
'......
Public Event CallingButton(ByVal d As Date)
Public calledbutton As calBut
Function CallButton(ByVal d As Date) As calBut
calledbutton = Nothing
RaiseEvent CallingButton(d)
Return calledbutton
End Function
End Class
'calendar button class
Public Class calBut
Inherits Button
'......
Friend Sub OnCallingButton(ByVal d As Date)
If d = Me.Date Then
Dim parent As Calendar = DirectCast(Me.Parent, Calendar)
parent.calledbutton = Me
End If
End Sub
End Class