I am currently using the code below to hide certain columns, but it appears to still show them as visible. Any help is greatly appreciated.
grdAreas.WebWorksheets[0].BindColumns[0].Width = 0;
Thanks,
I am currently using the code below to hide certain columns, but it appears to still show them as visible. Any help is greatly appreciated.
grdAreas.WebWorksheets[0].BindColumns[0].Width = 0;
Thanks,
Hi,
Please put your line of code before WebWorksheet.DataBind() method.
e.g..,
//...........................
WebWorksheet sheet = GridWeb1.WebWorksheets[0];
// Clears the sheet.
sheet.Cells.Clear();
// Enables creating in-sheet headers.
sheet.EnableCreateBindColumnHeader = true;
// Data cells begin from row 2.
sheet.BindStartRow = 2;
// Creates some title cells.
sheet.Cells["A1"].PutValue("The Product Table");
sheet.Cells["A1"].Style.Font.Size = new FontUnit("20pt");
sheet.Cells["A1"].Style.HorizontalAlign = HorizontalAlign.Center;
sheet.Cells["A1"].Style.VerticalAlign = VerticalAlign.Middle;
sheet.Cells["A1"].Style.BackColor = Color.SkyBlue;
sheet.Cells["A1"].Style.ForeColor = Color.Blue;
// Hide the first column
sheet.BindColumns[0].Width = new Unit("0pt");
//Or
//sheet.BindColumns[0].Width = 0;
// Bind the sheet to the dataset.
sheet.DataBind();
}
finally
{
db.oleDbConnection1.Close();
}
Thank you.
Hi,
The BindColumn.Width will only take effect when databind is called.
I think you may use GridWeb1.WebWorksheets[0].Cells.SetColumnWidth(0, Unit.Point(0));