checked listbox to show new from

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

I'm using a checked list box to show the forms with this code
Private Sub lstExterior_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstExterior.SelectedIndexChanged

Select Case lstExterior.SelectedIndex

Case 0

Try

frmDem.Show()

Catch ex As ObjectDisposedException

' Catch the exception and deal with it

Exit Sub

End Try

End Select

End Sub

this is working except that when the checkbox is unchecked the form isnt
removed

also when rechecking the checkbox the form doesn't reappear

how do I incorporate the check value into the code

thanks Phil
 
Phil said:
I'm using a checked list box to show the forms with this code
Private Sub lstExterior_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lstExterior.SelectedIndexChanged

Select Case lstExterior.SelectedIndex

Case 0

Try

frmDem.Show()

Catch ex As ObjectDisposedException

' Catch the exception and deal with it

Exit Sub

End Try

End Select

End Sub

this is working except that when the checkbox is unchecked the form isnt
removed

also when rechecking the checkbox the form doesn't reappear

I am unsure if I understood your question correctly, but here is some code:

\\\
Private m_MainForm As MainForm
..
..
..
If _
Me.CheckedListBox1.GetItemChecked(Me.CheckedListBox1.SelectedIndex) _
Then
If m_MainForm Is Nothing OrElse m_MainForm.IsDisposed Then
m_MainForm = New MainForm()
m_MainForm.Show()
End If
Else
m_MainForm.Close()
End If
///
 
Back
Top