viable solution?

  • Thread starter Thread starter Nathan Carroll
  • Start date Start date
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top