[Implement] MonthCalendar Conponent

[Implement] MonthCalendar Conponent

參考 Canlendar其他說明 : http://www.codeproject.com/KB/selection/MonthCalendar.aspx

1.PNG


Pabo.Calendar.DateItem di = new Pabo.Calendar.DateItem();

private void PaintDateBackcolor(DateTime[] dt)
{
    for (int i = 0; i < dt.Length; i++)
    {
        diArray[i] = di;//加入DateItem
        diArray[i].Date = dt[i];//設定要塗上色塊的日期
        diArray[i].BackColor1 = Color.Red;//色塊顏色
    }
    mCal.AddDateInfo(diArray);//將日期色快加入自Canlendar中
}

//this.mCal.DaySelected += new Pabo.Calendar.DaySelectedEventHandler(this.mCal_DaySelected);

private void mCal_DaySelected(object sender, Pabo.Calendar.DaySelectedEventArgs e)
{
    //顯示日期在標籤中
    this.label1.Text = e.Days[0].ToString();

    //將所選取的日期塗上色塊
    PaintDateBackcolor(new DateTime[] { Convert.ToDateTime(e.Days[0].ToString()) });
}

private void Form1_Load(object sender, EventArgs e)
{
    //將該日期塗上色塊
    DateTime[] dt = new DateTime[] { new DateTime(2011, 9, 25) };
    PaintDateBackcolor(dt);

    //設定今天日期的顏色
    mCal.TodayColor = Color.Blue;
}