View Full Version : Me.MonthCalendar1 or Me.Calendar1
jleone
10-05-2007, 03:31 PM
OK, question about the use of calendars on Web Forms or Win Forms. I have no problems getting them to function properly. My question is more of the calendar visually. Is there any property in the control (I've looked through all of the intelli-sense and I'm not seeing anything) to only show the current month when the calendar is visible?
For example, for the month of October, the calendar is showing September 30 through November 10. I really don't want to see that extra week and half into November. In my optinion, it makes the calendar for the month too big and bulky. I just really don't want to see those extra dates - I just want to see October 1 through October 31.
Any help is appreciated.
jleone
10-05-2007, 03:46 PM
OK, there is a TrailingForeColor property that lets you set the color for the dates of the previouse and following months. I set that to Transparent and you don't see the dates, but I can't make the calendar size smaller than 178 wide and 155 height in Win Forms. This still doesn't do me any good since the goal of this was to reduce to size of the calendar and not show the other dates. Any feedback is still appreciated.
nikkiH
10-05-2007, 08:05 PM
You would probably have to roll your own, use third party (there are a ton), or make the font size smaller.
Freon22
10-05-2007, 11:33 PM
I never messed with the calendar control before. So I thought I would play with it some. For a web form I was able to display the calendar without it showing the month days before or after. But the problem I have with this now is when you first load the page the calendar is blank. It does have its header and if you click to the next month then back again the current month will display the way that you want. But somewhere I am missing something when it first loads. :confused:
Protected Sub Calendar1_DayRender1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date.Month <> Calendar1.VisibleDate.Month Then
e.Cell.Text = String.Empty
End If
End Sub
Anyway no time left to play with it anymore today. Does anyone else know what I maybe missing?
nikkiH
10-05-2007, 11:43 PM
Does setting the text to empty not render the cell at all, though?
The issue is the size of the control, and for a windows form, you can't make it smaller than the entire thing takes to render, whether the text is visible or not. You end up with a line of blank cells, but the cells are still there.
Freon22
10-06-2007, 12:52 AM
He did say.
OK, question about the use of calendars on Web Forms or Win Forms.
But you are right all it does is make the cells that are not of the current month empty. He is going to have a sizing problem no matter unless like what you said "use third party" control. Most months begins and ends in the middle of a week. So those rolls are going to be there in some cases no matter what.
Freon22
10-08-2007, 03:11 PM
Code for current month only. Works good or I should say I am happy with it. lol
Protected Sub Calendar1_DayRender1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.IsOtherMonth Then
e.Cell.Text = ""
End If
End Sub
jleone
10-08-2007, 06:35 PM
Hey there -
Thanks for all the feedback. Everyone here seems to understand what I am trying to accomplish. Yes, I don't want to see the days from the other months, but I am trying to reduce the size of the calendar as well.
Like I said for instance right now for the month of October, this month ends on a Wednesday, but the calendar displays another full week into November, all the way to the 10th. I don't care to see that whole other week. Ending on Saturday, November 3rd would be preferred.
No sense to dig into this any further. I am just going to live with it. I am a developer that writes apps that are used in-house for the company I work for, so it's not that big a deal. It's just something I was trying to figure out.
Thanks again.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.