VS.NET(C#)-4.7_Calendar控件

Calendar控件

主要事件

l  SelectionChanged

l  DayRender

l  VisibleMonthChanged

protected void Calendar1_SelectionChanged(object sender, EventArgse)

    {

        lblTodaysDate.Text = "Today's Date is :"+ Calendar1.TodaysDate.ToShortDateString();

        if(Calendar1.SelectedDate != DateTime.MinValue)

        {

            lblSelected.Text = "选择日期: " +Calendar1.SelectedDate.ToShortDateString();

        }

        lblCount.Text = "已选天数:"+Calendar1.SelectedDates.Count.ToString();

        lbl01.Text= Calendar1.SelectedDate.DayOfYear.ToString();

   }

Calendar1.TodaysDate属性、SelectedDate属性均会返回System.DateTime类型的值

DateTime类具有多个方法将DateTime对象转换为其他格式

ToFileTime

ToLongDateString

ToLongTimeString

ToShortTimeString

ToString

 

DateTime的只读属性

名称

类型

说明

Date

DateTime

返回月份中的日期

Day

Integer

 

DayOfWeek

DayOfWeek

 

DayOfYear

Integer

 

Hour

Integer

 

Minute

Integer

 

Month

Integer

 

Second

Integer

 

Ticks

Long

 

TimeOfDay

TimeSpan

 

Year

Integer

返回年部分

 

VisibleDat

        显示月份的日期

        protected void Page_Load(objectsender, EventArgs e)

    {

        if(!IsPostBack)

        {

            cld.VisibleDate = cld.TodaysDate;

            cld.SelectedDate = cld.TodaysDate;

            ddl.SelectedIndex =cld.VisibleDate.Month - 1;

        }

   }

       

        protected void ddl_SelectedIndexChanged(object sender, EventArgs e)

    {

        cld.SelectedDates.Clear();

        //通过下拉列表构造需要显示的月份的日期

        cld.VisibleDate = new DateTime(cld.VisibleDate.Year,Int32.Parse(ddl.SelectedItem.Value),1);

        //cld.SelectedDate= cld.VisibleDate;

   }

 

DayOfWeek  显示一个中所有星期五

        protected void btnTGIF_Click(objectsender, EventArgs e)

    {

        intcurrentMonth = cld.VisibleDate.Month;

        intcurrentYear = cld.VisibleDate.Year;

        cld.SelectedDates.Clear();

        for(int i = 1; i <System.DateTime.DaysInMonth(currentYear,currentMonth);i++)

        {

            DateTimev_Date = new DateTime(currentYear,currentMonth,i);

            if(v_Date.DayOfWeek == DayOfWeek.Friday)

            {

                cld.SelectedDates.Add(v_Date);

            }

        }

   }

SelectedDates.SelectRange  选择范围

        protected void btnRange_Click(objectsender, EventArgs e)

    {

        intcurrentMonth = cld.VisibleDate.Month;

        intcurrentYear = cld.VisibleDate.Year;

        DateTimestartDate = new DateTime(currentYear,currentMonth,Int32.Parse(txtStart.Text));

        DateTimeendDate = new DateTime(currentYear,currentMonth, Int32.Parse(txtEnd.Text));

        cld.SelectedDates.Clear();

       cld.SelectedDates.SelectRange(startDate,endDate);

   }

 

DayRender事件

        在Calendar控件呈现到客户端浏览器之前,将创建该控件的所有组件,随着创建每个单元格,将引发DayRender事件

DayRender事件处理程序接收两个DayRenderEventArgs类型参数。该对象有两个属性

Ø  Cell  表示单元格对象

Ø  Day  表示呈现在单元格中日期的CalendarDay对象

protected void cld_DayRender(objectsender, DayRenderEventArgs e)

    {

        //在单元格中显示Happy birthday

        if(e.Day.Date.Month==8 && e.Day.Date.Day == 9)

        {

            e.Cell.Controls.Add(new LiteralControl("<br/> Happy Birthday!"));

        }

        //显示春节快乐!

        if(e.Day.Date.Month == 2 && e.Day.Date.Day == 15)

        {

            e.Cell.Controls.Add(new LiteralControl("<br/> 春节快乐!"));

        }

    }

VisibleMonthChanged事件

        确定用户是否更改了月份。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
net framework4.7.2安装包,这款net framework4.72工具包是最新离线版,nbsp;.NET Framework 4.7.2是针对Microsoft .NET Framework 4、4.5、4.5.1、4.5.2、4.6、4.6.1和4.6.2的就地更新,兼容性良好,支持独立安装。本款net framework4.7.2官方版是玩家们游戏的必备插件,帮助玩家们顺利体验游戏。.NET Framework 4.7.2的更新内容: 支持Windows10上的Windows Forms应用高分辨率设置支持Windows10上的WPF应用触摸增强加密支持支持C# 7和VB 15,包括ValueTuple支持.NET标准v1.6性能和可靠性提升使用方法1.下载解压缩2.直接安装net framework4.7工具包3.重启电脑生效适应系统:.NET Framework 4支持的操作系统:Windows Server 2003; Windows Server 2008; Windows Server 2008R2; Windows Vista; Windows XP; Windows 7.NET Framework 4.5支持的操作系统:Windows 7;Windows 8 ;Windows Server 2008;Windows Server 2008 R2;Windows Server 2012.NET Framework 4.6支持的操作系统:Windows 7 Service Pack 1, Windows 8, Windows 8.1, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 2012, Windows Server 2012 R2, Windows Vista Service Pack 2注意:Windows 8和 Windows Server 2012 已包括 .NET Framework 4.5。因此,您不必在这些操作系统上安装此软件。Microsoft .NET Framework 4.7适用于Windows 7 SP1、Windows 8.1、Windows 10一周年更新、Windows Server 2008 R2 SP1、Windows Server 2012、Windows Server 2012 R2和Windows Server 2016。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值