kirti zare

kirti zare

  • NA
  • 10
  • 1.7k

MdiChildren Length Incorrect When Closing Application

Jul 24 2015 7:26 AM
Hello,

1. I am making an application in which i am using mdiform and having multiple child form

2. I am using previous and next button to navigate from one child to another

following is my code
Private Sub Form1_MdiChildActivate(sender As Object, e As EventArgs) Handles MyBase.MdiChildActivate
Dim frmact = Me.ActiveMdiChild
Dim i = Array.IndexOf(Me.MdiChildren, frmact)

If i = 0 AndAlso Me.MdiChildren.Length = 1 Then
btnNext.Enabled = False
btnPrevious.Enabled = True
ElseIf i = 0 AndAlso Me.MdiChildren.Length > 1 Then
btnNext.Enabled = True
btnPrevious.Enabled = False
ElseIf i = Me.MdiChildren.Length - 1 Then
btnNext.Enabled = False
btnPrevious.Enabled = True
Else
btnNext.Enabled = True
btnPrevious.Enabled = True
End If

If Me.ActiveMdiChild Is Nothing Then
btnNext.Enabled = False
btnPrevious.Enabled = False

End If
End Sub

but when i am closing the mdichild form mdichildrenlength showing in correct
If you have any solution then i like to use that solution

Thanks in advance