I populate BindinSource with this collection:

=================
public class PreliminaryPickupRequest
{
private string shipper;
public string Shipper
{
get { return shipper; }
set { shipper = value; }
}

private Terminal pickupTerminal;
public Terminal PickupTerminal
{
get { return pickupTerminal; }
set { pickupTerminal = value; }
}
}


public class Terminal
{
private int key;
public int Key
{
get { return key; }
set { key = value; }
}

private string number;
public string Number
{
get { return number; }
set { number = value; }
}
}

=============================

Here is the problem:

I can bind Shipper column:

DataGridViewColumn c = new DataGridViewTextBoxColumn();
c.HeaderText = "Shipper";
c.Width = 300;
c.DataPropertyName = "Shipper";
dgvMain.Columns.Add(c);


but I cannot do this:

DataGridViewColumn c = new DataGridViewTextBoxColumn();
c.HeaderText = "Terminal";
c.Width = 300;
c.DataPropertyName = "Terminal.Number";
dgvMain.Columns.Add(c);

Is there a way to do it?

Thanks,

-Stan

Re: BindingSource - how can I access nested member? by RobinS

RobinS
Thu Apr 26 22:42:31 CDT 2007

Expose the members of Terminal through the PreliminaryPickupRequest class
as noted below.

Robin S.
------------
"StanB" <stan@community.nospam.com> wrote in message
news:%23ZhBKLAiHHA.4976@TK2MSFTNGP03.phx.gbl...
>I populate BindinSource with this collection:
>
> =================
> public class PreliminaryPickupRequest
> {
> private string shipper;
> public string Shipper
> {
> get { return shipper; }
> set { shipper = value; }
> }
>
> private Terminal pickupTerminal;
> public Terminal PickupTerminal
> {
> get { return pickupTerminal; }
> set { pickupTerminal = value; }
> }



public int TerminalKey
{
get {return pickupTerminal.Key;}
set {pickupTerminal.Key = value;}
}
public string TerminalNumber
{
get {return pickupTerminal.Number;}
set {pickupTerminal.Number = value;}
}



> }
>
>
> public class Terminal
> {
> private int key;
> public int Key
> {
> get { return key; }
> set { key = value; }
> }
>
> private string number;
> public string Number
> {
> get { return number; }
> set { number = value; }
> }
> }
>
> =============================
>
> Here is the problem:
>
> I can bind Shipper column:
>
> DataGridViewColumn c = new DataGridViewTextBoxColumn();
> c.HeaderText = "Shipper";
> c.Width = 300;
> c.DataPropertyName = "Shipper";
> dgvMain.Columns.Add(c);
>
>
> but I cannot do this:
>
> DataGridViewColumn c = new DataGridViewTextBoxColumn();
> c.HeaderText = "Terminal";
> c.Width = 300;
> c.DataPropertyName = "Terminal.Number";
> dgvMain.Columns.Add(c);
>
> Is there a way to do it?
>
> Thanks,
>
> -Stan
>