Hello,
I'm very new to Visual Basic 2005 and getting myself rather confused.
I am trying to use a number of checkboxes on a search page within an application (it's a search restricted to certain keywords, hence the checkboxes). Then in the results page I want each checked box to display a panel related to that keyword that is imported from another form.
So, for example, say the checkbox for 'snake' was checked. I want the snake panel from frmReptiles to display in an empty panel on the results page.
I currently have three checkboxes on the search page and three empty panels on the results page for loading the imported panels. I'm using panels so I can import all the text, pictures etc within the panel. However, I don't want there to be gaps in the final display if, say the second checkbox wasn't checked. So I'm trying to get the code to get the checked box-related panels to display in the top most empty panels on the results page. I'd earlier figured out how to do it by using set panels with visible turned on or off based on the checked state, but that left big gaps if not all checkboxes were selected.
My current code is okay first run through but if I go back to the search page and change the checked boxes I receive an 'ObjectDisposedException was unhandled'. I'm guessing it needs to reset itself but it's beyond me what to do there. I'm sure there is a much more elegant way to do this but this is the code I have at the moment:
CODE
Public Class frmResults
Private Sub frmResults_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If frmSearch.chkboxPenguins.CheckState = 1 And _
frmSearch.chkboxShark.CheckState = 1 And _
frmSearch.chkboxSnake.CheckState = 1 Then
panelResults1.Controls.Add(frmBirds.panelPenguins)
panelResults2.Controls.Add(frmFish.panelShark)
panelResults3.Controls.Add(frmReptiles.panelSnake)
ElseIf frmSearch.chkboxPenguins.CheckState = 1 And _
frmSearch.chkboxShark.CheckState = 1 And _
frmSearch.chkboxSnake.CheckState = 0 Then
panelResults1.Controls.Add(frmBirds.panelPenguins)
panelResults2.Controls.Add(frmFish.panelShark)
ElseIf frmSearch.chkboxPenguins.CheckState = 1 And _
frmSearch.chkboxShark.CheckState = 0 And _
frmSearch.chkboxSnake.CheckState = 1 Then
panelResults1.Controls.Add(frmBirds.panelPenguins)
panelResults2.Controls.Add(frmReptiles.panelSnake)
ElseIf frmSearch.chkboxPenguins.CheckState = 1 And _
frmSearch.chkboxShark.CheckState = 0 And _
frmSearch.chkboxSnake.CheckState = 0 Then
panelResults1.Controls.Add(frmBirds.panelPenguins)
ElseIf frmSearch.chkboxPenguins.CheckState = 0 And _
frmSearch.chkboxShark.CheckState = 1 And _
frmSearch.chkboxSnake.CheckState = 1 Then
panelResults1.Controls.Add(frmFish.panelShark)
panelResults2.Controls.Add(frmReptiles.panelSnake)
ElseIf frmSearch.chkboxPenguins.CheckState = 0 And _
frmSearch.chkboxShark.CheckState = 1 And _
frmSearch.chkboxSnake.CheckState = 0 Then
panelResults1.Controls.Add(frmFish.panelShark)
Else
panelResults1.Controls.Add(frmTest.panelKangaroo)
End If
End Sub
Any assistance will be much appreciated.
Thanks,
micaelita