C#DateTime Range Find [英] C# DateTime Range Find

查看:117
本文介绍了C#DateTime Range Find的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家,



我有一个类似下面的代码,我在日历2012/05/03的日历中采访。



我的问题是,我必须强调一个日期范围,如2012/05 / 03-2012 / 05/15,我该怎么办?



  var  ce =  new  CustomEvent( ); 
ce.IgnoreTimeComponent = false ;
ce.EventText = 采访;
ce.Date = new DateTime( 2012 5 3 );

解决方案

如果你正在使用asp压光控制然后



通过使用ondayrender属性,我们可以突出显示特定日期(通过改变背景/前景色)





in.aspx页面

 <  < span class =code-leadattribute> asp:Calendar     ID   =  Calendar1    runat   =  server    ondayrender   =  MyDayRenderer >  
$ b $ in aspx.cs页面

< pre lang = cs > protected void MyDayRenderer(object sender,DayRenderEventArgs e)
{
if(e.Day.IsToday)
{
e.Cell.BackColor = System.Drawing.Color.Aqua;
}

if(e.Day.Date == new DateTime(2011,5,1))
{
e.Cell.BackColor = System.Drawing .Color.Beige;
}
} < / pre >


Dear Experts,

I have a code like below which I am highliting Interview in my calender for the Date 2012/05/03.

My problem is, I have to highlight a range of date like 2012/05/03-2012/05/15, how can I do it?

var ce = new CustomEvent();
ce.IgnoreTimeComponent = false;
ce.EventText = "Interview";
ce.Date = new DateTime(2012, 5, 3);

解决方案

If you are using asp calender control then

By using ondayrender property we can highlight particular dates(by changing background/fore color)


in.aspx page

<asp:Calendar ID="Calendar1" runat="server" ondayrender="MyDayRenderer">

in aspx.cs page

<pre lang="cs">protected void MyDayRenderer(object sender, DayRenderEventArgs e)
    {
        if (e.Day.IsToday)
        {
            e.Cell.BackColor = System.Drawing.Color.Aqua;
        }

        if (e.Day.Date == new DateTime(2011,5,1))
        {
            e.Cell.BackColor = System.Drawing.Color.Beige;
        }
    }</pre>


这篇关于C#DateTime Range Find的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆