Print Page | Close Window

How Do I make specified Days Bold in DatePicker

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=10395
Printed Date: 02 June 2024 at 1:49pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How Do I make specified Days Bold in DatePicker
Posted By: LeeHayton
Subject: How Do I make specified Days Bold in DatePicker
Date 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



Replies:
Posted By: dentor
Date 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
 


Posted By: LeeHayton
Date 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


Posted By: dentor
Date 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.
 


Posted By: LeeHayton
Date 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
 
 
 


Posted By: dentor
Date 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.
 


Posted By: LeeHayton
Date 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


Posted By: dentor
Date 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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net