Solved

MonthCalendar selection and bolding

Posted on 2009-04-08
6
396 Views
Last Modified: 2013-11-26
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
Comment
Question by:mgordon-spi
  • 3
  • 2
6 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24104829
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24105768
0
 

Author Comment

by:mgordon-spi
ID: 24121374
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 48

Expert Comment

by:jpaulino
ID: 24122292
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
 

Author Comment

by:mgordon-spi
ID: 24127152
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
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24127179
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
in Dot net,lastest version of MVC 3 33
Help with exporting to excel 4 35
Name Space error VS2015 1 22
Adding items to a C# list incrementally 5 28
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question