コード例 #1
0
 public static DataGridView MakeEmptyTimeTable(DataGridView dgv, DataGridView dgv2, string Name, params string[] Time)          //获取时间段对应的空白单元格
 {
     for (int num = 0; num < Time.Length; num++)
     {
         int            Row;
         int            Columns;
         string         OldNameString = "";
         RowsAndColumns RC            = GetRowsAndColumns(dgv, Time[num]);
         RowsAndColumns RC2           = GetRowsAndColumns(dgv2, Time[num]);
         Row     = RC2.Rows;
         Columns = RC2.Columns;
         for (int j = Columns + 1; j < dgv.ColumnCount; j++)
         {
             if (dgv.Rows[Row].Cells[j].Value.ToString() == string.Empty)
             {
                 if (dgv2.Rows[Row].Cells[j].Value == null)                          //第一次时候进行排版
                 {
                     dgv2.Rows[Row].Cells[j].Value = Name;
                 }
                 else
                 {
                     OldNameString = dgv2.Rows[Row].Cells[j].Value.ToString();
                     OldNameString = OldNameString + "," + Name;
                     dgv2.Rows[Row].Cells[j].Value = OldNameString;
                 }
             }
         }
     }
     return(dgv2);
 }
コード例 #2
0
 public static DataGridView PaintCell(DataGridView dgv2, Color color, params string[] CellString)         //给特定单元格上色
 {
     for (int num = 0; num < CellString.Length; num++)
     {
         RowsAndColumns RC = new RowsAndColumns();
         RC = GetRowsAndColumns(dgv2, CellString[num]);
         if (RC.Rows != -1 && RC.Columns != -1)
         {
             dgv2.Rows[RC.Rows].Cells[RC.Columns].Style.BackColor = color;
         }
     }
     return(dgv2);
 }
コード例 #3
0
        public static DataGridView PaintColumn(DataGridView dgv2, string HeaderCellString, string BottomCellString, Color color)         //对列进行上色
        {
            RowsAndColumns RC1 = new RowsAndColumns();
            RowsAndColumns RC2 = new RowsAndColumns();

            RC1 = GetRowsAndColumns(dgv2, HeaderCellString);
            RC2 = GetRowsAndColumns(dgv2, BottomCellString);
            for (int i = RC1.Rows; i <= RC2.Rows; i++)
            {
                for (int j = RC1.Columns; j <= RC2.Columns; j++)
                {
                    dgv2.Rows[i].Cells[j].Style.BackColor = color;
                }
            }
            return(dgv2);
        }
コード例 #4
0
ファイル: BLL.cs プロジェクト: KaminoDice/Jovi-s-Software
 //获取字段所在的行列
 public static RowsAndColumns GetRowsAndColumns(DataGridView dgv, string CellString)
 {
     RowsAndColumns RC = new RowsAndColumns();
     for (int i = 0; i < dgv.RowCount; i++)
     {
         for (int j = 0; j < dgv.ColumnCount; j++)
             if (dgv.Rows[i].Cells[j].Value != null)
                 if (dgv.Rows[i].Cells[j].Value.ToString() == CellString)
                 {
                     RC.Rows = i;
                     RC.Columns = j;
                     return RC;
                 }
     }
     return RC;
 }
コード例 #5
0
 public static DataGridView FillDayOrTime(DataGridView dgv, DataGridView dgv2, params string[] DayOrTime)          //填充星期或者时间
 {
     try
     {
         for (int num = 0; num < DayOrTime.Length; num++)
         {
             RowsAndColumns RC      = GetRowsAndColumns(dgv, DayOrTime[num]);
             int            Row     = RC.Rows + 1;
             int            Columns = RC.Columns;
             dgv2.Rows[Row].Cells[Columns].Style.BackColor = Color.Yellow;
             dgv2.Rows[Row].Cells[Columns].Value           = DayOrTime[num];             //将时间填入新的dgv2
         }
         return(dgv2);
     }
     catch
     {
         MessageBox.Show("制作不完整,请参照帮助,检查格式!", "警告 ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return(dgv2);
     }
 }
コード例 #6
0
        public static RowsAndColumns GetRowsAndColumns(DataGridView dgv, string CellString)          //获取字段所在的行列
        {
            RowsAndColumns RC = new RowsAndColumns();

            for (int i = 0; i < dgv.RowCount; i++)
            {
                for (int j = 0; j < dgv.ColumnCount; j++)
                {
                    if (dgv.Rows[i].Cells[j].Value != null)
                    {
                        if (dgv.Rows[i].Cells[j].Value.ToString() == CellString)
                        {
                            RC.Rows    = i;
                            RC.Columns = j;
                            return(RC);
                        }
                    }
                }
            }
            return(RC);
        }
コード例 #7
0
ファイル: BLL.cs プロジェクト: KaminoDice/Jovi-s-Software
 //对列进行上色
 public static DataGridView PaintColumn(DataGridView dgv2, string HeaderCellString, string BottomCellString, Color color)
 {
     RowsAndColumns RC1 = new RowsAndColumns();
     RowsAndColumns RC2 = new RowsAndColumns();
     RC1 = GetRowsAndColumns(dgv2, HeaderCellString);
     RC2 = GetRowsAndColumns(dgv2, BottomCellString);
     for (int i = RC1.Rows; i <= RC2.Rows; i++)
         for (int j = RC1.Columns; j <= RC2.Columns; j++)
             dgv2.Rows[i].Cells[j].Style.BackColor = color;
     return dgv2;
 }
コード例 #8
0
ファイル: BLL.cs プロジェクト: KaminoDice/Jovi-s-Software
 //给特定单元格上色
 public static DataGridView PaintCell(DataGridView dgv2, Color color, params string[] CellString)
 {
     for (int num = 0; num < CellString.Length; num++)
     {
         RowsAndColumns RC = new RowsAndColumns();
         RC = GetRowsAndColumns(dgv2, CellString[num]);
         if (RC.Rows != -1 && RC.Columns != -1)
             dgv2.Rows[RC.Rows].Cells[RC.Columns].Style.BackColor = color;
     }
     return dgv2;
 }