62,041
社区成员
发帖
与我相关
我的任务
分享
<table style="width:200px; height:200px; border-color:Red; border-collapse:collapse;">
<tr>
<td colspan="2" rowspan="2"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="2"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="2"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
String[] HH = { "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "01", "02", "03", "04", "05", "06", "07" };
String[] SS = { "00", "15", "30", "45" };
String[] Week = { "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日" };
protected void ShowTable()
{
TableRow tr;
TableCell tc;
int Count_Row_Sum = HH.Length * SS.Length; //获得行数
int Count_Col_Sum = Week.Length + 1; //获得列数
for (int Row_Count = 0; Row_Count < Count_Row_Sum + 1; Row_Count++)
{
tr = new TableRow();
//行数
#region if
if (Row_Count == 0)
{
//第一行标题
for (int Col_Count = 0; Col_Count < Count_Col_Sum; Col_Count++)
{
//列数
tc = new TableCell();
if (Col_Count >= 1)
{
//第一列
tc.Text = Week[Col_Count - 1];
}
else if (Col_Count == 0)
{
//第一行,第一列,跨2列4行
tc.ColumnSpan = 2;
}
tc.BackColor = Color.Brown;
tr.Cells.Add(tc);
}
}
else
{
#endregion
int c = (Row_Count - 1) / 4; //获取小时的数组的编号
int x = (Row_Count - 1) % 4; //获取分钟的数组的编号
//内容
if (x == 0)
{
for (int Col_Count = 0; Col_Count < Count_Col_Sum + 1; Col_Count++)
{
tc = new TableCell();
if (Col_Count == 0)
{
//第一列跨4行
tc.RowSpan = 4;
tc.Text = HH[c];
}
else if (Col_Count == 1)
{
//第二列不跨行
tc.Text = SS[x];
}
tr.Cells.Add(tc);
}
}
else
{
for (int Col_Count = 0; Col_Count < Count_Col_Sum; Col_Count++)
{
tc = new TableCell();
tc.Text = Row_Count + "-" + Col_Count;
if (Col_Count == 0)
{
//第二列不跨行
tc.Text = SS[x];
}
if (Row_Count % 2 == 0)
{
tr.BackColor = Color.Crimson;
}
else
{
tr.BackColor = Color.DarkViolet;
}
tr.Cells.Add(tc);
}
}
}
list.Controls.Add(tr);
}
}