checked listbox to show new from

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
 
H

Herfried K. Wagner [MVP]

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
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top