如何使C#DataView列不可见?我认为它与ReadOnly类似,但以下不起作用,因为没有“可见”属性。
foreach(DataColumn c in myDataView.Table.Columns)
{
if(visiblecolumns.Contains(c.ColumnName))
{
c.Visible = true;
}
else
{
c.Visible = false;
}
}
答案 0 :(得分:0)
请参阅:http://msdn.microsoft.com/en-us/library/bb383893%28v=vs.90%29.aspx
customersDataGridView.Columns[0].Visible = false;
已更新
SqlDataAdapter da = new SqlDataAdapter("SELECT Title,FirstName,LastName FROM
Employees",conn);
da.Fill(ds_orig);
ds_copy = ds_orig.Copy();
dt = ds_copy.Tables[0];
dt.Columns.Remove("Title");
dv = new DataView(dt);