How Do I make specified Days Bold in DatePicker |
Post Reply |
Author | |
LeeHayton
Senior Member Joined: 25 November 2005 Location: United Kingdom Status: Offline Points: 102 |
Post Options
Thanks(0)
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
|
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
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 |
|
LeeHayton
Senior Member Joined: 25 November 2005 Location: United Kingdom Status: Offline Points: 102 |
Post Options
Thanks(0)
|
Thanks - but how do I pass the day that I wanted - how do I call the procedure passing the date?
Regards
Lee
|
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
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.
|
|
LeeHayton
Senior Member Joined: 25 November 2005 Location: United Kingdom Status: Offline Points: 102 |
Post Options
Thanks(0)
|
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
|
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
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.
|
|
LeeHayton
Senior Member Joined: 25 November 2005 Location: United Kingdom Status: Offline Points: 102 |
Post Options
Thanks(0)
|
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
|
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |