添加文本后,webforms表变形

时间:2019-03-04 16:20:31

标签: c# asp.net webforms

因此,我需要将“ ”添加到颜色相同等最大的位置的单元格中。当我将“ ”添加到单元格中时,表格看起来很难看,变形了:How looks table after adding "" 不添加“ ”:How table looks without adding any text to a cell

我该如何解决?我不介意制造更大的细胞。

    void CreateTable(int[,] Table, Demė deme, int[,] colorTable) //Demė is spot
    {
        for (int i = 0; i < Table.GetLength(0); i++)
        {
            TableRow row = new TableRow();
            for (int j = 0; j < Table.GetLength(1); j++)
            {
                TableCell red = new TableCell();
                red.BackColor = Color.Red;
                red.Text = " ";
                TableCell green = new TableCell();
                green.BackColor = Color.Green;
                green.Text = " ";
                TableCell yellow = new TableCell();
                yellow.BackColor = Color.Yellow;
                yellow.Text = " ";
                if (colorTable[i, j] == -1)
                {
                    if (Table[i, j] == deme.ID)
                    {
                        red.Text = "*";
                    }
                    row.Cells.Add(red);
                }
                else if (colorTable[i, j] == -2)
                {
                    if (Table[i, j] == deme.ID)
                    {
                        green.Text = "*";
                    }
                    row.Cells.Add(green);
                }
                else if (colorTable[i, j] == -3)
                {
                    if (Table[i, j] == deme.ID)
                    {
                        yellow.Text = "*";
                    }
                    row.Cells.Add(yellow);
                }
            }

            Table1.Rows.Add(row);
        }
    }

0 个答案:

没有答案