一下是Test 的代码,比如想锁定1 2 两列(或动态锁定某几列)该如何实现?
void Bind_Load(int columns_Count,int row_Count)
{
dt = new DataTable();
for (int i = 0; i < columns_Count; i++)
{
dt.Columns.Add("Column_" + i, typeof(string));
}
for (int j = 0; j < row_Count; j++)
{
dr = dt.NewRow();
for (int i = 0; i < columns_Count; i++)
{
dr["Column_" + i] = j == 0 ? i * 10 : (j+i) * 10;
}
dt.Rows.Add(dr);
}
tb.Width = (columns_Count * 80).ToString();
foreach (DataRow dr in dt.Rows)
{
HtmlTableRow tr = new HtmlTableRow();
tr.Height = "25"; tr.Align = "left"; tr.VAlign = "middle";
foreach (DataColumn dc in dt.Columns)
{
HtmlTableCell td = new HtmlTableCell();
td.Align = "center"; td.BgColor = "#f3f8fd"; td.Align = "center";
if (dc.Caption == "Column_0" || dc.Caption == "Column_1")
{
td.Attributes.CssStyle.Add("LEFT", "expression(this.offsetParent.scrollLeft)");
td.Attributes.CssStyle.Add("POSITION", "relative");
}
td.InnerHtml = string.Format("<b>{0}</b>",dr[dc].ToString());
tr.Cells.Add(td);
tb.Rows.Add(tr);
}
}
}