B
Boaz Ben-Porat
Is there an attribute for a property on an object that saus :"This property
is not shown on a DataGrid" ?
I know it can be done on the grid itself, using DataGridTableStyle,
DataGridColumnStyle etc. But I`d like to get the same result by changing my
class, not at run-time changing grid`s behaveiour.
A small example:
public class User
{
private string m_Uid;
private string m_Name;
private string m_Pwd;
// UID should be visible on a DataGrid
public string UID
{
get {return m_Uid;}
set {m_Uid = value;}
}
// Name should be visible on a DataGrid
public string Name
{
get {return m_Name;}
set {m_Uid = Name;}
}
// PWD should *NOT* be visible on a DataGrid
//is there an attribute for this ?
[SomeAttribute.PreventBindingToGrid(true)] // this is what I`m looking
for
public string PWD
{
get {return m_Pwd;}
set {m_Pwd = value;}
}
} // End of User.
On a form with a DataGrid - gridUsers, We implement (implementation not
shown) a method to fetch users into an ArrayList of User objects, and bind
gridUsers to the list:
ArrayList alUsers = FetchUsers();
gridUsers.DataSource = alUsers; // Currently, the grid has 3 columns,
including PWD.
Can this be done (prevent PWD property from binding) ?
TIA Boaz Ben-Porat
DataPharm a/s
Denmark
is not shown on a DataGrid" ?
I know it can be done on the grid itself, using DataGridTableStyle,
DataGridColumnStyle etc. But I`d like to get the same result by changing my
class, not at run-time changing grid`s behaveiour.
A small example:
public class User
{
private string m_Uid;
private string m_Name;
private string m_Pwd;
// UID should be visible on a DataGrid
public string UID
{
get {return m_Uid;}
set {m_Uid = value;}
}
// Name should be visible on a DataGrid
public string Name
{
get {return m_Name;}
set {m_Uid = Name;}
}
// PWD should *NOT* be visible on a DataGrid
//is there an attribute for this ?
[SomeAttribute.PreventBindingToGrid(true)] // this is what I`m looking
for
public string PWD
{
get {return m_Pwd;}
set {m_Pwd = value;}
}
} // End of User.
On a form with a DataGrid - gridUsers, We implement (implementation not
shown) a method to fetch users into an ArrayList of User objects, and bind
gridUsers to the list:
ArrayList alUsers = FetchUsers();
gridUsers.DataSource = alUsers; // Currently, the grid has 3 columns,
including PWD.
Can this be done (prevent PWD property from binding) ?
TIA Boaz Ben-Porat
DataPharm a/s
Denmark