Microsoft Engineers , others: Datagrid related q.

J

JimGreen

I have an arraylist that contains following objects
class Name
{
string _FirstName;
public string FirstName
{
get{return _FirstName;}
}
string _LastName;
public string LastName
{
get{return _LastName;}
}

}

class CustomerInfo
{
Name _CustomerName;
long _Id
public Name CustomerName
{
get { return _CustomerName;}
}
public int CustomerId
{
get{return _Id;}
}
}

I am adding objects of CustomerInfo to the arraylist and I am attaching
the arraylist to the datagrid.
I want to display Id and First Name in the datagrid.

I used DataGridTableStyle to attach CustomerId
DataGridTextBoxColumn cs = new DataGridTextBoxColumn();
cs.MappingName = "CustomerId"; //public property name
cs.HeaderText = "Customer Id";
cs.Width = colwidth;
ts.GridColumnStyles.Add(cs);


but I don't know how can I add FirstName column to the grid. I tried
something like this:

cs.MappingName = "Name.FirstName"; //DID NOT WORK???
cs.HeaderText = "Customer Id";
cs.Width = colwidth;
ts.GridColumnStyles.Add(cs);

I will appreciate any help
Thanks
 
C

Cor Ligthert [MVP]

Jim,

Maybe do you have a reason, however why not use a datatable instead of an
arraylist.

A datatable fits 1 to 1 to a datagrid.
(And therefore there is much more knowledge about it)

Just my thought,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top