ARTICLE AD BOX
It's a very simple problem, but a bit tricky to explain (hence the diagrams).
I have a ListView. Clicking on an item refreshes a Panel with the data of the clicked item.
Each item has a property value of 1 or 2.
I want the tab of a TabControl to be selected in the Panel following the value of 1 or 2.

The Panel has a Leave event.
This allows for automatic saving of data before displaying the next clicked ListView item.
When successive clicked ListView items have the same property (1 or 2), the TabControl remains unchanged.

The problem occurs when TabControl needs to change (from 1 to 2 or vice versa).

The `Leave` event is triggered even when the mouse isn't hovering over the Panel. This results in unexpected saving of the ListView item as soon as it's clicked, during display, with side effects and (I strongly suspect) data loss.
My initial idea was to prevent the Panel's `Leave` event from occurring during Panel refresh.
then, after the display:
DonneesPanel.Leave += DonneesPanel_Leave;It's not working. I don't understand why, especially because :
DonneesPanel.Enter -= DonneesPanel_Enter; DonneesPanel.Enter += DonneesPanel_Enter;works !
Summary: Whenever TabControl needs to change, the Panel's _Leave event is triggered. The form that is currently loading is saved, and I can't prevent it.
When a ListView item is clicked, I can refresh everything in the Panel, including the TabControl.
It's only when the properties of the clicked item require changing the TabControl's tab that a Leave event from the Panel is triggered after the display.
This is what I want to avoid.
I'm not using a custom control. TabControl, ListView and Panel are the ones from Windows Forms.
Thank you for your help.
