Ok, I'll spend one more try on this and then I'll close this thread. Please read the post below carefully, as it's important you read everything I explain below.
yogiberr wrote:
morning
Ok, in the NorthwindExampleCS that you attached, the winform that is most similar to mine
is: "CustomerManager.cs"
<customerManagerGui>
1) combobox that displays customers..the combobox "drives" the databinding.
2) ordersDataGrid that displays orders, based on the current CUSTOMER.
3) orderDetailsDataGrid that displays order details, based on current ORDER.
Total 3x entities
</customerManagerGui>
You can't create that in one go without coding. That's also why there's code in the form which binds the orderdetails.
The thing is: you have a master-detail-superdetail in this 3 -layer setup:
master (customers)
detail (orders)
superdetail (order details).
The currencymanager on a form, can control a master and a detail, and keep them in sync. you do this in general by binding the collection to both grids, and set the datamember in the detail grid.
As you thus can see, you can't setup a superdetail with the same approach, as you then would have to bind the same collection also to the superdetail grid (thus customers again) and set the datamember to ... "orders.orderdetails", but that's not supported.
That's also why in the form, the orders and order details are bound manually and are bound to the orders collection. so the 'orders' is the master and orderdetails is the details. This leads to the fact that when an order is selected, the order details are selected automatically, by the currencymanager on the form.
Keyword is "in-sync": the currency manager on the forum has to keep everything in sync: what's selected in the master influences the details and what selected in the details influences the superdetails.
Because this SYNC problem is the ROOT CAUSE of finding which collection to set AllowRemove to true.
So when I take my example, and replace the Order details grid with a datagridview, and add this code to the BindOrders routine:
foreach(OrderEntity order in _currentCustomer.Orders)
{
order.OrderDetails.AllowRemove = true;
}
I can remove a row in the orderdetails by just pressing DEL. This is because I know which collection's to set allowRemove to true to. Though this is a pretty harsh loop. I also can bind an event handler to the Orders' grid event which is raised when I select a row. In there, I know which order is bound, as it's the entity object in the row. I then also know which collection to set the allowremove for, as that's the collection in that entity object.
I hope you'll understand that this is all winform databinding related material, not our code related material. You didnt post the bindingsource stack you used in your test with the example I gave you, so I can't rebuild that here.
Now, to get rid of this problem, you can also use a different approach, an include template which simply sets all contained entity collections in an entity's AllowRemove property to true. Also pretty harsh, as it doesnt' care about collection nor context the entity is used in, so perhaps not what you want.
So, without you and us losing any more time on this: I gave you an example, which allowed you to reproduce your problem. WHat I would like to ask you is to alter THAT example so it shows your problem and attach that example (just the GUI project, that's enough) to your reply. That will then allow us to see what's wrong, as this current track is going no-where as we keep on getting miscommunications back and forth and that just stalls your progress.
That example just contains northwind code, so it should be straight forward for us to reproduce the prob. (A problem which is solely about 'how to setup master-detail-superdetail databinding in winforms', i.e. a generic problem)