I have a ListBox and 2 DataGridViews.
I have an Object which has
[Serializable]
public class Process
{
...
public string ProcessName { get; set; }
public List<Step> Steps { get; set; }
}
[Serializable]
public class Step
{
...
public List<StepEvent> StepEvents { get; set; }
}
[Serializable]
public class StepEvent
{
...
public int EventId { get; set; }
}
I can connect the listbox and the first grid, but I can not hook up the second grid. I don't think I can use a DataRelation because its an object not a DataTable
Code So Far
List<Process> processes = new XMLHelper().CreateObject<List<Process>>(GetXmlProcess());
listProcess.DataSource = processes;
listProcess.DisplayMember = "ProcessName";
listProcess.ValueMember = "ProcessName";
dgSteps.DataSource = processes;
dgSteps.DataMember = "Steps";
//List<Step> steps = (from p in processes
// from st in p.Steps
// select st).ToList();
dgStepEvents.DataSource = processes;
dgStepEvents.DataMember = "Steps.StepEvents";
No matter what I make dgStepEvents.DataMember it gives me an error. As you can see I tried LINQ but then [steps] is a new object and doesn't link.
2nd related question: I have been reading a lot of BindableSource but I figured I didn't need something like that since the listview and the datagrid are already in sync.