protected void Button1_Click(object sender, EventArgs e)
    {
        int current_day = Calendar1.VisibleDate.Day;
        int current_month = Calendar1.VisibleDate.Month;
        int current_year = Calendar1.VisibleDate.Year;
        Calendar1.SelectedDates.Clear();
        // Loop through current month and add all Wednesdays to the collection.
        for (int i = 1; i <= System.DateTime.DaysInMonth(current_year,
               current_month); i++)
        {
            DateTime targetDate = new DateTime(current_year, current_month, i);
            if (targetDate.DayOfWeek == DayOfWeek.Wednesday)
                Calendar1.SelectedDates.Add(targetDate);
        }
        Text1.Text = "Selection Count =" + Calendar1.SelectedDates.Count;
    }

解决方案 »

  1.   

    Calendar1控件不就可以做到了么,你是要吧Calendar1的值赋给文本框??
    还是点击文本框出现Calendar1?
      

  2.   

    TextBox1.Text = Calendar1.SelectedDate.ToString("yyyy-MM-dd");
      

  3.   

    如何点击textbox触发Calendar1,让Calendar1显示
      

  4.   

    先把textBox1的Visible属性设为false.
    private void textBox1_Enter(object sender, EventArgs e)
            {
                monthCalendar1.Visible = true;;
            }
    private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
            {
                textBox1.Text = monthCalendar1.SelectionStart.ToString("yyyy-MM-dd");
                monthCalendar1.Visible = false;
            }
      

  5.   

    不好意思,我用的是monthCalendar.