BindingSource - how can I access nested member?

  • Thread starter Thread starter StanB
  • Start date Start date
S

StanB

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
 
Expose the members of Terminal through the PreliminaryPickupRequest class
as noted below.

Robin S.
------------
StanB said:
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;}
}
 
Back
Top