1

I have a set of coordinates for each Coordinate Type

CoordinateSet X Y Z
Z50 123456 4567890 445.3
Z51 234567 9876543 445.3
LatLong 112.45 83.250 NULL

I would like them displayed in a WPF Datagrid along with other data but flattened out.

A B C Z50 Z51 LatLong
??? ??? ??? X Y Z X Y Z X Y Z
123456 4567890 445.3 234567 9876543 445.3 112.45 83.250 NULL

I have tried putting the XYZ Data as a datatable inside a datatable with columns of Z50, Z51, LatLong as typeof (DataTable) but this does not work.

The data only needs to be displayed, not edited.

Is this possible in WPF C#?

Regards

Quentin
  • 21
  • 3
  • "I have tried putting the XYZ Data as a datatable inside a datatable with columns of Z50, Z51, LatLong as typeof (DataTable) but this does not work" - if done properly, DataTable should be the simplest way to do it – ASh Nov 24 '22 at 10:45

1 Answers1

1

I managed to get it to work using a DataTable inside a DataTable. Code below for reference.

CoordsDataTable = new();

    foreach (var coordset in DrillDesigns.Coordinates)
    {
        CoordsDataTable.Columns.Add(coordset!.CoordinateType!.CoordinateType, typeof(DataTable));
    }

    CoordsDataTable.Rows.Add();

    foreach (var coordset in DrillDesigns.Coordinates)
    {
        CoordsDataSet = new();
        CoordsDataSet.Columns.Add("X");
        CoordsDataSet.Columns.Add("Y");
        CoordsDataSet.Columns.Add("Z");
        CoordsDataSet.Rows.Add(coordset.X, coordset.Y, coordset.Z);
        CoordsDataTable.Rows[0][coordset!.CoordinateType!.CoordinateType] = CoordsDataSet;
    }
Quentin
  • 21
  • 3