如何使C#DataView列不可见?

时间:2011-01-26 20:40:06

标签: c# dataview

如何使C#DataView列不可见?我认为它与ReadOnly类似,但以下不起作用,因为没有“可见”属性。

foreach(DataColumn c in myDataView.Table.Columns)
{
    if(visiblecolumns.Contains(c.ColumnName))
    {
        c.Visible = true;
    }
    else
    {
        c.Visible = false;
    }
}

1 个答案:

答案 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);