Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

MonthCalendar selection and bolding

I have a MonthCalendar control that I want to display multiple selected date ranges.

I have got dates bolding at the moment, but I need them to be selected.
Dim dgvRow As DataGridViewRow = Me.dgvLeave.Rows(e.RowIndex)
  
        calHolidayCalendar.RemoveAllBoldedDates()
        Dim startDate As DateTime = dgvRow.Cells(1).Value
        Dim endDate As DateTime = dgvRow.Cells(2).Value
 
        Dim timeSpan As TimeSpan = endDate.Subtract(startDate)
        Dim selectedDates As DateTime() = New DateTime(timeSpan.Days) {}
 
        For index As Integer = 0 To selectedDates.Length - 1
            calHolidayCalendar.AddBoldedDate(startDate.AddDays(Convert.ToDouble(index)))
 
        Next
 
        calHolidayCalendar.UpdateBoldedDates()

Open in new window

0
mgordon-spi
Asked:
mgordon-spi
  • 3
  • 2
1 Solution
 
jpaulinoCommented:
Hi,
You can use SelectionRange to define your selection. Something like:
 

        Dim rg As New SelectionRange
        rg.Start = startDate
        rg.End = endDate
 
        Me.calHolidayCalendar.SelectionRange = rg

Open in new window

0
 
CodeCruiserCommented:
0
 
mgordon-spiAuthor Commented:
Hi All,

Thanks for the responses. I am aware of the SelectionRange  - however I need to be able to have multiple ranges selected at once.

The only way I have ben able to do that is by setting the dates Bold.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
jpaulinoCommented:
I don't think you can do that. You can only have one selection range active.
Bold dates seems to be the solution on use any other custom control
0
 
mgordon-spiAuthor Commented:
In that case, is it possible to overload the calendar control and change the bold style? I know its possible with the WEB Calendar control, but cant seem to find a way to do this with the winforms control. If we could at least change the forcolor of any dates that are set to bold then this wold be an adequate solution.
0
 
jpaulinoCommented:
MonthCalendar as allot limitations and you cannot work as you want with him. Why don't you use another custom and free control like this one:
 Another Month Calendar
http://www.codeproject.com/KB/selection/MonthCalendar.aspx
 You can also find some more in here:
http://www.codeproject.com/KB/selection/
 
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now