将文本框添加到日历中的每个日期

时间:2015-02-26 16:46:26

标签: c# calendar

在以下日历示例中,如果我选择多个或一系列日历日并输入文本,则会在所有选定日期添加1个文本框控件,与Outlook中的相同。怎么能让日历进入一个单独的文本框控件,每天都有相同的文本,将所有这些文件合并到一个文本框中?谢谢

http://www.codeproject.com/Articles/38699/A-Professional-Calendar-Agenda-View-That-You-Will

public void CreateItemOnSelection(string itemText, bool editMode)
{
    if (SelectedElementEnd == null || SelectedElementStart == null) return;

    CalendarTimeScaleUnit unitEnd = SelectedElementEnd as CalendarTimeScaleUnit;
    CalendarDayTop dayTop = SelectedElementEnd as CalendarDayTop;
    CalendarDay day = SelectedElementEnd as CalendarDay;
    TimeSpan duration = unitEnd != null ? unitEnd.Duration : new TimeSpan(23, 59, 59);
    CalendarItem item = new CalendarItem(this);

    DateTime dstart = SelectedElementStart.Date;
    DateTime dend = SelectedElementEnd.Date;

    if (dend.CompareTo(dstart) < 0)
    {
        DateTime dtmp = dend;
        dend = dstart;
        dstart = dtmp;
    }

    item.StartDate = dstart;
    item.EndDate = dend.Add(duration);
    item.Text = itemText;

    CalendarItemCancelEventArgs evtA = new CalendarItemCancelEventArgs(item);

    OnItemCreating(evtA);

    if (!evtA.Cancel)
    {
        Items.Add(item);

        if (editMode)
        {
            _creatingItem = true;
            ActivateEditMode(item);
        }
    }
}

0 个答案:

没有答案