MonthCalendar.FirstDayOfWeek : MonthCalendar « System.Windows.Forms « C# / C Sharp by API

Home
C# / C Sharp by API
1.Microsoft.Win32
2.System
3.System.Collections
4.System.Collections.Generic
5.System.Collections.Specialized
6.System.ComponentModel
7.System.Configuration
8.System.Data
9.System.Data.Common
10.System.Data.Linq
11.System.Data.Odbc
12.System.Data.OleDb
13.System.Data.Sql
14.System.Data.SqlClient
15.System.Diagnostics
16.System.DirectoryServices
17.System.Drawing
18.System.Drawing.Drawing2D
19.System.Drawing.Imaging
20.System.Drawing.Printing
21.System.Drawing.Text
22.System.EnterpriseServices
23.System.Globalization
24.System.IO
25.System.IO.Compression
26.System.IO.IsolatedStorage
27.System.IO.Ports
28.System.Linq
29.System.Management
30.System.Media
31.System.Messaging
32.System.Net
33.System.Net.Mail
34.System.Net.NetworkInformation
35.System.Net.Sockets
36.System.Reflection
37.System.Resources
38.System.Runtime
39.System.Runtime.CompilerServices
40.System.Runtime.InteropServices
41.System.Runtime.Remoting
42.System.Runtime.Remoting.Channels
43.System.Runtime.Remoting.Channels.Http
44.System.Runtime.Remoting.Messaging
45.System.Runtime.Serialization
46.System.Runtime.Serialization.Formatters.Binary
47.System.Runtime.Serialization.Formatters.Soap
48.System.Security
49.System.Security.AccessControl
50.System.Security.Cryptography
51.System.Security.Cryptography.X509Certificates
52.System.Security.Permissions
53.System.Security.Policy
54.System.Security.Principal
55.System.ServiceProcess
56.System.Text
57.System.Text.RegularExpressions
58.System.Threading
59.System.Timers
60.System.Web.Security
61.System.Web.Services
62.System.Windows.Controls
63.System.Windows.Forms
64.System.Xml
65.System.Xml.Linq
66.System.Xml.Schema
67.System.Xml.Serialization
68.System.Xml.XPath
69.System.Xml.Xsl
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp by API » System.Windows.Forms » MonthCalendar 
MonthCalendar.FirstDayOfWeek
 


using System;
using System.Drawing;
using System.Windows.Forms;

public class Calendar : Form
{
  MonthCalendar mc;
  DateTimePicker dtpStart;    
  DateTimePicker dtpEnd;    
  DateTimePicker dtpBold;    
  Label lblStart;
  Label lblEnd;
  Label lblStartDay;
  Label lblBold;
  ComboBox cmbStart;
  Button btnBoldDay;
  Button btnBoldMonthly;
  Button btnBoldAnnually;

  public Calendar()
  {
    Size = new Size(650,450);
    this.Load += new EventHandler(this_Load);

    mc = new MonthCalendar();
    mc.Parent = this;
    mc.Location = new Point(20,20);
    mc.Font = new Font("Times New Roman"14);
    mc.CalendarDimensions = new Size(2,1);
    mc.FirstDayOfWeek = Day.Monday;
    mc.MaxSelectionCount = 45;
    mc.DateChanged += new DateRangeEventHandler(mc_DateChanged);
    mc.DateSelected += new DateRangeEventHandler(mc_DateSelected);

    lblStart = new Label();
    lblStart.Parent = this;
    lblStart.Text = "Start Date:";
    
    dtpStart = new DateTimePicker();
    dtpStart.Parent = this;
    dtpStart.Size = new Size((int)(Font.Height * .6
              dtpStart.Value.ToString("D").Length,
              dtpStart.PreferredHeight);
    dtpStart.Format = DateTimePickerFormat.Long;
    dtpStart.ShowUpDown = true;
    dtpStart.ValueChanged += new EventHandler(dtpStart_ValueChanged);

    lblEnd = new Label();
    lblEnd.Parent = this;
    lblEnd.Text = "End Date:";
    
    dtpEnd = new DateTimePicker();
    dtpEnd.Parent = this;
    dtpEnd.Size = new Size((int)(Font.Height * .6
              dtpEnd.Value.ToString("D").Length,
              dtpEnd.PreferredHeight);
    dtpEnd.Format = DateTimePickerFormat.Long;
    dtpEnd.ShowUpDown = true;
    dtpEnd.ValueChanged += new EventHandler(dtpEnd_ValueChanged);
        
    lblStartDay = new Label();
    lblStartDay.Parent = this;
    lblStartDay.Text = "Start Day:";
    
    cmbStart = new ComboBox();
    cmbStart.Parent = this;
    cmbStart.DropDownStyle = ComboBoxStyle.DropDownList;
    cmbStart.Items.AddRange(new object[] {"Monday"
                      "Tuesday"
                      "Wednesday"
                      "Thursday"
                      "Friday"
                      "Saturday"
                      "Sunday"});
    cmbStart.SelectedIndex = 0;
    cmbStart.SelectedIndexChanged += new EventHandler(cmbStart_SelectedIndexChanged);
    
    lblBold = new Label();
    lblBold.Parent = this;
    lblBold.Text = "Bold Day:";
    
    dtpBold = new DateTimePicker();
    dtpBold.Parent = this;
    dtpBold.Size = new Size((int)(Font.Height 
              dtpBold.Value.ToString("d").Length,
              dtpBold.PreferredHeight);
    dtpBold.Format = DateTimePickerFormat.Short;
    dtpBold.ShowUpDown = true;
    
    btnBoldDay = new Button();
    btnBoldDay.Parent = this;
    btnBoldDay.Text = "Add Bold Day";
    btnBoldDay.Size = new Size((int)(Font.Height * .6
                btnBoldDay.Text.Length,
                (int)(Font.Height * 1.75));
    btnBoldDay.Click += new EventHandler(btnBoldDay_Click);
    
    btnBoldMonthly = new Button();
    btnBoldMonthly.Parent = this;
    btnBoldMonthly.Text = "Add Bold Day Monthly";
    btnBoldMonthly.Size = new Size((int)(Font.Height * .6
                  btnBoldMonthly.Text.Length,
                  (int)(Font.Height * 1.75));
    btnBoldMonthly.Click += new EventHandler(btnBoldMonthly_Click);

    btnBoldAnnually = new Button();
    btnBoldAnnually.Parent = this;
    btnBoldAnnually.Text = "Add Bold Day Annually";
    btnBoldAnnually.Size = new Size((int)(Font.Height * .6
                    btnBoldAnnually.Text.Length,
                    (int)(Font.Height * 1.75));
    btnBoldAnnually.Click += new EventHandler(btnBoldAnnually_Click);
  }

  static void Main() 
  {
    Application.Run(new Calendar());
  }

  private void this_Load(object sender, EventArgs e)
  {
    lblStart.Location = new Point(mc.Left, mc.Bottom + 10);
    dtpStart.Location = new Point(lblStart.Right, mc.Bottom + 10);

    lblEnd.Location = new Point(mc.Left, lblStart.Bottom + 5);
    dtpEnd.Location = new Point(lblStart.Right, lblStart.Bottom + 5);
    
    lblStartDay.Location = new Point(mc.Left, lblEnd.Bottom + 5);
    cmbStart.Location = new Point(lblStart.Right, lblEnd.Bottom + 5);

    lblBold.Location = new Point(mc.Left, lblStartDay.Bottom + 5);
    dtpBold.Location = new Point(lblBold.Right, 
                  lblStartDay.Bottom + 5);
    
    btnBoldDay.Location = new Point(dtpBold.Right + 10, dtpBold.Top);
    btnBoldMonthly.Location = new Point(btnBoldDay.Right, 
                      dtpBold.Top);
    btnBoldAnnually.Location = new Point(btnBoldMonthly.Right, 
                      dtpBold.Top);
  }

  private void dtpStart_ValueChanged(object sender, EventArgs e)
  {
    mc.SelectionStart = dtpStart.Value;
  }    

  private void dtpEnd_ValueChanged(object sender, EventArgs e)
  {
    mc.SelectionEnd = dtpEnd.Value;
  }    

  private void mc_DateChanged(object sender, DateRangeEventArgs e)
  {
    MessageBox.Show("DateChanged");
    dtpStart.Value = e.Start;
    dtpEnd.Value = e.End;
  }

  private void mc_DateSelected(object sender, DateRangeEventArgs e)
  {
    MessageBox.Show("DateSelected");
  }

  private void cmbStart_SelectedIndexChanged(object sender, 
                        EventArgs e)
  {
    mc.FirstDayOfWeek = (Day)cmbStart.SelectedIndex;
  }

  private void btnBoldDay_Click(object sender, EventArgs e)
  {
    mc.AddBoldedDate(dtpBold.Value);
    mc.UpdateBoldedDates();
  }

  private void btnBoldMonthly_Click(object sender, EventArgs e)
  {
    mc.AddMonthlyBoldedDate(dtpBold.Value);
    mc.UpdateBoldedDates();
  }

  private void btnBoldAnnually_Click(object sender, EventArgs e)
  {
    mc.AddAnnuallyBoldedDate(dtpBold.Value);
    mc.UpdateBoldedDates();
  }
}

   
  
Related examples in the same category
1.new MonthCalendar()
2.MonthCalendar.BoldedDates
3.MonthCalendar.CalendarDimensions
4.MonthCalendar.DateChanged
5.MonthCalendar.DateSelected
6.MonthCalendar.MaxSelectionCount
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.