Posted 7 October 2022, 12:27 am EST - Updated 7 October 2022, 12:35 am EST
I have a WPF form with two grids on it as shown in the image. The top grid is a (SF) SyncFusion DataGrid and the bottom grid is a (C1) C1:Flexgrid.
In the XAML, both grids are bound to the same source Data Table in the same way
<c1:FlexGrid ItemsSource="{Binding DtBookings}"...
<DataGrid ItemsSource="{Binding DtBookings}"...
When I click on the grid I want the entire Booking object available to me so I fill the datatable like this and bind the grid to it:
The DataType of dtBookings is a “Booking” object:
dt.DataType = typeof(Booking);
The “Booking” object is a complex class containing other complex classes, namely the “Person” object, So we can have for example: (Customer is a Person object).
Booking.Customer.DisplayName;
Finally the Booking.ToString() is overridden so that when it is bound to a control instead of seeing “Bookings.Models.Booking” written into the celltext we can see something useful like customer’s name “John Doe”.
public override string ToString()
{
return base.Customer.DisplayName;
}
When I run the code above the SF grid is populated and the C1 is not.
If I change the dtBookings.DataType from Booking to Person:
dt.DataType = typeof(**Person**);
and then populate the datatable with the Bookings.Customer then the C1 grid will work and display the contents too.
So effectively C1 will see Booking.Person.ToString(); But it won’t see Booking.ToString();
But of course I only have the Person object now and not the entire Booking.
Even if I change the ToString() to a local variable like return Bookings.HelloWorld it won’t work.
Why is the C1 Flexgrid not displaying the Booking Object, but it will display the Person object?!