所选日期想要使用csharp在datagridview中显示 [英] selected date want to display in datagridview using csharp

查看:55
本文介绍了所选日期想要使用csharp在datagridview中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设计如下





日历(控制名月月历)



注意:它是windows应用程序。





运行模式如下;



在运行模式下,当我选择任何月份并点击时,那个月所有日期都要显示在dategridview中。





我的代码如下;



Design as follows


Calendar (control name month calendar)

Note: it is windows application.


Run mode as follows;

In the run mode when i select any month and click, that month all dates want to display in dategridview.


My code as follows;

private void Facavailcal_DateChanged(object sender, DateRangeEventArgs e)
      {

        DateTime dt1 = Facavailcal.TodayDate;
           dt1 = new DateTime(dt1.Year, dt1.Month, 1);
           DateTime dt2 = dt1.AddMonths(1);
           int numDays = (dt2 - dt1).Days;

           if (DGVCalendar.RowCount < numDays)
           {
               DGVCalendar.RowCount = numDays;
           }

           int row = 0;
           while (dt1 < dt2)
           {
               DGVCalendar.Rows[row].Cells[0].Value = dt1.ToString("dd/MM/yyyy");
               dt1 = dt1.AddDays(1);
               row++;

           }


      }





<上面代码中的
,在日历2月份的运行模式中,当我选择那个月显示在datagridview中时。



假设当我选择行军月份时,该月份日期不会显示在dategridview中。





来自我上面的代码是什么问题。



请帮帮我。




in the above code, in the run mode in the calendar february month is there,when i select the that month is display in datagridview.

suppose when i select march month means, that month date is not display in dategridview.


from my above code what is the problem.

please help me.

推荐答案

你好b $ b

只需更改以下行即可工作

而不是DateTime dt1 = Facavailcal.TodayDate;

以下使用

DateTime dt1 = Facavailcal.SelectionStart < br $>




您的代码是正确的,但您每次都要尝试选择相同的日期。
Hi
Just Change below line and it will work
instead DateTime dt1 = Facavailcal.TodayDate;
use below
DateTime dt1 = Facavailcal.SelectionStart


Your Code is correct but you trying to select same date every time.


这篇关于所选日期想要使用csharp在datagridview中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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