在Windows应用程序中使用datagrid添加行 [英] add rows using datagrid in windows application

查看:67
本文介绍了在Windows应用程序中使用datagrid添加行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个日期选择器如下。





Datepicker1 DAtepicker2
当我选择datepicker1时,
星期一作为星期一在星期六第13天星期六自动显示在datepicker2没问题。



i希望输出为



第8到第13个日期将在行中显示如下。当我点击按钮时。



我在datepicker1中选择的日期添加5天,并将日期显示到datepicker2.when我点击日期网格中行显示日期的加载按钮。

输出如下



i have tow date picker as follows.


Datepicker1 DAtepicker2
when i choose datepicker1 8th day as monday in the datepicker 2 13th day saturday automically display in the datepicker2 no problem.

i want the output as

that 8th to 13th date will be diplayed in the row wise as follows.when i click the button.

what date i choose in the datepicker1 add 5 days and display that date to the datepicker2.when i click the load button that date to be displayed in the row wise in the date grid.
output as follows

DAte SS      GS     VR    CKK    CNN    RV   MS    TSS    CM

 8   1

 8   2

 8   3

 9   1

 9   2

 9   3

 10  1

 10  2

 10  3

 11  1

 11  2

 11  3

 12  1

 12  2

 12  3

 13  1

 13  2

 13  3





该输出如何在Windows应用程序中使用csharp编写代码。



代码块添加 - OriginalGriff [/ edit]



for that output how to write the code using csharp in windows application.

[edit]Code block added - OriginalGriff[/edit]

推荐答案

你可以试试这样的东西。这只是您的想法的示例代码,您可以根据需要修改此代码。

You can try something like this. This is just a sample code for your thought you can modify this code based on your need.
private void UpdateGrid(DateTime time, int noOfDays)
{
  for (int i = 1; i <= noOfDays; i++)
  {
     DateTime newDate = time.AddDays(i);

     for (int newIndex = 0; newIndex < 3; newIndex++)
     {
       DataGridViewRow row = new DataGridViewRow();

       row.Cells[0].Value = newDate.ToShortDateString();
       row.Cells[1].Value = newIndex;

       this.dataGridView1.Rows.Add(row);
                  
     }
   }
}


这篇关于在Windows应用程序中使用datagrid添加行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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