Here is a quick windows forms calendar code.

I used a TableLayoutPanel with Dock=Fill.

private void FillDays()
        {
            DateTime FirstDay = new DateTime(DateTime.Now.Year, 
			DateTime.Now.Month, 1);
 
            int col = GetNumOfWeekDay(FirstDay.DayOfWeek);
            int row = 0;
            for (int i = 1; i < DateTime.DaysInMonth(DateTime.Today.Year, 
				DateTime.Today.Month)+1; i++, col++)
            {
                if (col > 6)
                {
                    col = 0;
                    row++;
                }
                Label lbl = new Label();
                lbl.Text = i.ToString();
 
                tlpCalendar.Controls.Add(lbl, col, row);
            }
        }
 
        private int GetNumOfWeekDay(DayOfWeek dow)
        {
            return (Int32)Enum.Parse(typeof(DayOfWeek), dow.ToString());
        }
VN:F [1.1.6_502]
Rating: 3.0/5 (1 vote cast)
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati

Related posts:

  1. Find your lucky number in c#
  2. T-SQL Find previous month
  3. Build DateTime from values
  4. WinForms – Print using printDialog and printDocument
  5. Find the Quarter which a month belongs