How bind list of object contain dictionary type to a datasource of a datagridview?

  • Thread starter Thread starter Sayyid Ayoub kokabi
  • Start date Start date
S

Sayyid Ayoub kokabi

Guest
public class Instrument
{
public string SerialNumber { get; private set; }
public InstrumentSpec Spec { get; set; }

public Instrument(string serialNumber, InstrumentSpec spec)
{
SerialNumber = serialNumber;
Spec = spec;
}

//...
}

public class InstrumentSpec
{
public Dictionary<string, object> Properties { get; set; }
//...
}

public class Inventory
{
private List<Instrument> _inventory;

public IEnumerable<Instrument> GetAllInstrument()
{
return _inventory.Select(instrument => instrument);
}
//...
}


dataGridInstruments.DataSource =

//How use linq to see all instrument with their properties like bellow table?


+--------------+-------+--------+--------+------+--------------+
| SerialNumber | Color | Length | Weight | Name | CreationDate |
+--------------+-------+--------+--------+------+--------------+
| 100 | red | 150 | 50 | | 1987 |
| 200 | | 60 | 40 | CJ-5 | |
| 300 | green | 400 | 100 | MM | 1990 |
+--------------+-------+--------+--------+------+--------------+

Continue reading...
 
Back
Top