ControlRemoved event is called before control is removed (?)

0
0

Hi,

 

So, I have a FlowLayoutControl which starts empty but after a button is pressed a control is added to it. When said control is disposed I want something to happen.

Private Sub Panel_ControlContainer_ControlRemoved(sender As Object, e As ControlEventArgs) Handles Panel_ControlContainer.ControlRemoved

If IsChanging = False Then

If Panel_ControlContainer.Controls.Count = 0 Then

If Width < 500 Then

Panel_ControlContainer.Visible = False
NavigationBar1.Dock = DockStyle.Fill

End If

End If

End If

End Sub

 

This example is what I’m testing for in code when a control is removed. There can only be 1 control in the “Panel_ControlContainer”. The problem is that Panel_ControlContainer.Controls.Count returns > 0 eventhough a control was removed (the only control).

Could it be that this event is triggered before the control is actually removed?

(I add a new control to Panel_ControlContainer.controls at runtime when a user clicks a NavigationBarItem)

If needed I can provide (partially) the source

Thanks in advance!

Vincent

  • You must to post comments
0
0

Cannot reproduce. I get the correct count in ControlAdded and ControlRemoved events.

  • You must to post comments
0
0

Hi Vincent,

can you please share the code? You can also send it to supportATwisej.com if you prefer.

Thanks in advance,
Frank

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.