Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - How Do I make specified Days Bold in DatePicker
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How Do I make specified Days Bold in DatePicker

 Post Reply Post Reply
Author
Message
LeeHayton View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 November 2005
Location: United Kingdom
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote LeeHayton Quote  Post ReplyReply Direct Link To This Post Topic: How Do I make specified Days Bold in DatePicker
    Posted: 29 April 2008 at 6:46am
I would like to make some of the days appear bold or hightlighted in some way on the DatePicker control.  I do not wish these to disappear when the user clicks on a date etc.
 
Thanks
Lee
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 29 April 2008 at 7:04am
You can use DayMetrics Event to hightlight some dates in the datePicker.
 
For example, if you want to highlight all the sundays:
 
Private Sub DatePicker_DayMetrics(ByVal Day As Date, ByVal Metrics As XtremeCalendarControl.IDatePickerDayMetrics)
    If Weekday(Day) = vbSunday Then
        Metrics.ForeColor = vbRed
    End If
End Sub
 
Back to Top
LeeHayton View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 November 2005
Location: United Kingdom
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote LeeHayton Quote  Post ReplyReply Direct Link To This Post Posted: 29 April 2008 at 11:44am
Thanks - but how do I pass the day that I wanted - how do I call the procedure passing the date?
 
Regards
Lee
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 29 April 2008 at 12:07pm
Hello,
 
here's an example to set an icon to holyday date and red to sunday:
 
Private Sub DatePicker_DayMetrics(ByVal Day As Date, ByVal Metrics As XtremeCalendarControl.IDatePickerDayMetrics)
    ' *** Holyday is a function that test if date is holyday
    If Holyday(Day) Then
        Set Metrics.Picture = Img.picture
    ElseIf Weekday(Day) = vbSunday Then
        Metrics.ForeColor = vbRed
    End If
End Sub
 
Hope, it will help you.
 
Back to Top
LeeHayton View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 November 2005
Location: United Kingdom
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote LeeHayton Quote  Post ReplyReply Direct Link To This Post Posted: 29 April 2008 at 12:19pm
Thanks - but I'm afraid it doesn't help me.
 
Imagine the DatePicker was displaying April.
 
How do I make the following days bold using code in the form load:
 
e.g. 5th 6th and 17th
 
 
 
I'm sorry if I'm not getting it - I can see exactly how you can alter the attributes if a date is clicked on with the mouse and the event is triggered - but I want to bold or highlight specified dates from code.
 
Thanks again
Lee
 
 
 
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 29 April 2008 at 12:38pm
In the DayMetrics event, you can get the date (Day) that is displaying by the DatePicker control. You can then compare that date with the date you want to be highlighted.
 
Private Sub DatePicker_DayMetrics(ByVal Day As Date, ByVal Metrics As XtremeCalendarControl.IDatePickerDayMetrics)
    ' *** Holyday is a function that test if date is holyday
    If Day = "01/04/2008" Then
        Metrics.Font.Bold = true
    End If
End Sub
 
You can highligh the 01/04/2008.
 
Back to Top
LeeHayton View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 November 2005
Location: United Kingdom
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote LeeHayton Quote  Post ReplyReply Direct Link To This Post Posted: 30 April 2008 at 4:49am
Thanks - that works fine - I needed to set the AskDayMetrics property to TRUE to make it work.
 
I was actually expecting to be able to pick a date anywhere within my code (other procedures) and specify something like DatePicker1.date(MyDate).metrics.font.bold = true - but I can make it work well by using the following code.
 
 
Private Sub DatePicker1_DayMetrics(ByVal Day As Date, ByVal Metrics As XtremeCalendarControl.IDatePickerDayMetrics)
    rsBatch.Seek "=", 1, Day
    If Not rsBatch.NoMatch Then Metrics.Font.Bold = True
End Sub
 
 
Thanks Again.
Lee
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 30 April 2008 at 7:14am
You're right, I forgot to mention the AskDayMetrics property to make it works.
 
If you wish to get only one date to be hightlighted, you can use Tag property of the DatePicker to set the date to be display bold.
 
The sub below set the date display in bold font (if Dt="" then no date is display bold):
 
Private Sub HighLightDate(Dt As String)
    DatePicker1.Tag = Dt
    DatePicker1.RedrawControl
End Sub
 
The DayMetrics Event modified to take care of the Tag property :
 
Private Sub DatePicker1_DayMetrics(ByVal Day As Date, ByVal Metrics As XtremeCalendarControl.IDatePickerDayMetrics)
    If DatePicker1.Tag = "" Then Exit Sub
    If Day = DatePicker1.Tag Then
        Metrics.Font.Bold = True
    End If
End Sub

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.