我正在动态地将行和列添加到表格中,但我无法调整第一列的宽度。我尝试了“单位”的所有可能组合(新单位(300,单位类型.Point)) -但没有快乐。它总是显示该列中数据的列宽到长度,但我希望它是固定的。请问这里出了什么问题。
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tc = new TableCell();
tc.ID = "tcResource";
tc.Text = "Resource_Name";
Unit uWidth = new Unit(300, UnitType.Point);
tc.Width = uWidth;
tr.Cells.Add(tc);
for (i = 1; i <= 365; i++)
{
tc = new TableCell();
tc.ID = "tc" + i.ToString();
tc.Text = dtStart.AddDays(i).ToString("dd/MM") ;
dtRange[i - 1] = dtStart.AddDays(i );
tr.Cells.Add(tc);
}
tHoliday.Rows.Add(tr);
请您参考如下方法:
试试这个
Unit width = new Unit(30, UnitType.Pixel);
TableCell cell = new TableCell();
cell.Width = width;
