Hi
I think that you can use this code, for any datasource, to hide your column:
public void Item_Bound(Object sender, DataGridItemEventArgs e)
{
foreach(TableCell cell in e.Item.Cells)
{
if(cell.Text == "MessageText") cell.Visible = false;
}
}
Giorgio
"ITnerd" <> ha scritto nel messaggio
news:i6GdnfgDYMWKVDyiRVn-...
> The following code works to hide specific columns before they are bound to
a
> datagrid that has "autogeneratecolumns=true"
> enabled. My question is: is there any way to do the same from a bindable
> user defined collection? I have a "message" class that I don't want to
have
> to
> munge into a DataTable to get the desired effect.
>
> public void Item_Bound(Object sender, DataGridItemEventArgs e)
> {
>
> DataTable dt = MyDataGrid.DataSource as DataTable;
> DataColumnCollection dc = dt.Columns;
> e.Item.Cells[dc.IndexOf(dc["MessageText"])].Visible = false;
>
> }
>
> Thanks in advance.
>
>
>
|