C
Chen Naikun
hi,
I have difficulty on how to customize CF2.0 DataGrid bind with
BindingList<Business Object>.
I have a customer type :
internal class Customer
{
private Guid _id;
private int _name;
public Guid ID
{
get{return _id;}
set { _id = value; }
}
public string Name
{
get{return _name;}
set{_name=value;}
}
}
in windows form, i don't want display the property id to user, i have tried
this:
public partial class datagridtest : Form
{
private System.ComponentModel.BindingList<Customer> _list = new
BindingList<testClass>();
public datagridtest()
{
InitializeComponent();
dataGrid1.DataSource = _list;
//dataGrid1.TableStyles.Clear();
DataGridTableStyle tableStyle1 = new DataGridTableStyle();
DataGridColumnStyle columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = "Name";
columnStyle.MappingName = "Name";
tableStyle1.GridColumnStyles.Add(columnStyle);
dataGrid1.TableStyles.Add(tableStyle1);
}
private void datagridtest_Load(object sender, EventArgs e)
{
for(int i = 0 ; i < 10; i++)
{
Customer c = new Customer();
c.ID = System.Guid.NewGuid();
c.Name= "Naikun";
_list.Add(test);
}
}
}
but when form showed, the grid have two columns, one is ID,the other one is
Name!
any help is apprecied
I have difficulty on how to customize CF2.0 DataGrid bind with
BindingList<Business Object>.
I have a customer type :
internal class Customer
{
private Guid _id;
private int _name;
public Guid ID
{
get{return _id;}
set { _id = value; }
}
public string Name
{
get{return _name;}
set{_name=value;}
}
}
in windows form, i don't want display the property id to user, i have tried
this:
public partial class datagridtest : Form
{
private System.ComponentModel.BindingList<Customer> _list = new
BindingList<testClass>();
public datagridtest()
{
InitializeComponent();
dataGrid1.DataSource = _list;
//dataGrid1.TableStyles.Clear();
DataGridTableStyle tableStyle1 = new DataGridTableStyle();
DataGridColumnStyle columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = "Name";
columnStyle.MappingName = "Name";
tableStyle1.GridColumnStyles.Add(columnStyle);
dataGrid1.TableStyles.Add(tableStyle1);
}
private void datagridtest_Load(object sender, EventArgs e)
{
for(int i = 0 ; i < 10; i++)
{
Customer c = new Customer();
c.ID = System.Guid.NewGuid();
c.Name= "Naikun";
_list.Add(test);
}
}
}
but when form showed, the grid have two columns, one is ID,the other one is
Name!
any help is apprecied