Welcome to Dream.In.Code
Become a VB Expert!

Join 137,382 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,097 people online right now. Registration is fast and FREE... Join Now!




Checkboxes & displaying results

 
Reply to this topicStart new topic

Checkboxes & displaying results, Show panels in results based on checked boxes

micaelita
12 Oct, 2008 - 05:18 AM
Post #1

New D.I.C Head
*

Joined: 10 Sep, 2008
Posts: 4

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
User is offlineProfile CardPM
+Quote Post

Reverand Dave
RE: Checkboxes & Displaying Results
12 Oct, 2008 - 06:04 AM
Post #2

D.I.C Regular
Group Icon

Joined: 27 Jul, 2008
Posts: 373



Thanked: 2 times
Dream Kudos: 50
My Contributions
this is vb.net
User is offlineProfile CardPM
+Quote Post

thava
RE: Checkboxes & Displaying Results
12 Oct, 2008 - 05:31 PM
Post #3

D.I.C Regular
Group Icon

Joined: 17 Apr, 2007
Posts: 456



Thanked: 18 times
Dream Kudos: 50
My Contributions
the ref form's are not available in memory the error is occured

since the controls are reference type that's why the error

i think use the new keyword from panel


i am not sure for better and perfect results go to vb.net forum and post there some one will solve your problem
User is offlineProfile CardPM
+Quote Post

micaelita
RE: Checkboxes & Displaying Results
12 Oct, 2008 - 07:24 PM
Post #4

New D.I.C Head
*

Joined: 10 Sep, 2008
Posts: 4

I must apologise, I'm very new to the code so it's all 'Visual Basic' to me at the moment. I saw the 'free Visual Basic 2005' ebook thread at the top of the forum and figured this was the right place and that VB.net was something else entirely. Now I've read the post explaining the VB6 vs. VB.net differences and understand a little better. Thankyou for your time anyway. I will, as you suggest, try the VB.net forum.

Best wishes,

micaelita
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/5/08 01:54AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month