Results 1 to 2 of 2

Thread: [RESOLVED] [2008] Can't change Panel visibility?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    150

    Resolved [RESOLVED] [2008] Can't change Panel visibility?

    Yo!

    I've created a class, clsWizardStep, to hold the data for the 'steps' for my 'application configuration wizard' and one of the properties of this class is simply to hold which Panel will be visible during the defined step.

    The steps are stored in a List(Of clsWizardStep). When I try to set the panel visible, the change in boolean value for the property doesn't take effect.

    So culling off any code I can't see being necessary, here's what I've got. Sorry to make this so long, at least I've remembered to include some code!

    My class...

    vb.net Code:
    1. Public Class clsWizardStep
    2.  
    3.     Private _Title As String
    4.     Private _Description As String
    5.     Private _Panel As Panel
    6.     Private _ButtonText_Prev As String
    7.     Private _ButtonText_Next As String
    8.  
    9.     Public Property Title() As String
    10.         Get
    11.             Return _Title
    12.         End Get
    13.         Set(ByVal value As String)
    14.             _Title = value
    15.         End Set
    16.     End Property
    17.  
    18.     Public Property Description() As String
    19.         Get
    20.             Return _Description
    21.         End Get
    22.         Set(ByVal value As String)
    23.             _Description = value
    24.         End Set
    25.     End Property
    26.  
    27.     Public Property Panel() As Panel
    28.         Get
    29.             Return _Panel
    30.         End Get
    31.         Set(ByVal value As Panel)
    32.             _Panel = value
    33.         End Set
    34.     End Property
    35.  
    36.     Public Property ButtonText_Prev() As String
    37.         Get
    38.             Return _ButtonText_Prev
    39.         End Get
    40.         Set(ByVal value As String)
    41.             _ButtonText_Prev = value
    42.         End Set
    43.     End Property
    44.  
    45.     Public Property ButtonText_Next() As String
    46.         Get
    47.             Return _ButtonText_Next
    48.         End Get
    49.         Set(ByVal value As String)
    50.             _ButtonText_Next = value
    51.         End Set
    52.     End Property
    53.  
    54. End Class

    Function to add an item to the list:

    vb.net Code:
    1. Public Sub WizardSteps_AddStep(ByVal lstList As List(Of clsWizardStep), ByVal strTitle As String, ByVal strDescription As String, ByVal pnlPanel As Panel, ByVal strButtonText_Prev As String, ByVal strButtonText_Next As String)
    2.  
    3.         Dim thisStep As New clsWizardStep
    4.         thisStep.Title = strTitle
    5.         thisStep.Description = strDescription
    6.         thisStep.Panel = pnlPanel
    7.         thisStep.ButtonText_Prev = strButtonText_Prev
    8.         thisStep.ButtonText_Next = strButtonText_Next
    9.  
    10.         lstList.Add(thisStep)
    11.  
    12.     End Sub

    And in this function, I try to change the Visible property of the panel:

    vb.net Code:
    1. Private Sub Wizard_Next() Handles btnNext.Click
    2.  
    3.         If intCurrentPosition < (lstWizardSteps.Count - 1) Then
    4.  
    5.             intCurrentPosition += 1
    6.  
    7.             lblHeader.Text = lstWizardSteps(intCurrentPosition).Title
    8.             lblStepDescription.Text = lstWizardSteps(intCurrentPosition).Description
    9.             btnPrev.Text = lstWizardSteps(intCurrentPosition).ButtonText_Prev
    10.             btnNext.Text = lstWizardSteps(intCurrentPosition).ButtonText_Next
    11.  
    12.             Dim thisPanel As Panel
    13.             thisPanel = lstWizardSteps(intCurrentPosition).Panel
    14.             thisPanel.Visible = True
    15.  
    16.             Debug.WriteLine(thisPanel.Visible)
    17.  
    18.         Else
    19.             'Perform a Save?
    20.             MessageBox.Show("This is where you save your settings...")
    21.             Me.Close()
    22.         End If
    23.  
    24.     End Sub

    The list works fine, the items are created. The properties for the class are set. The panels exist.

    I've tried a few different methods for setting the property, none have worked.
    I.e.
    vb.net Code:
    1. Dim thisPanel As Panel
    2.             thisPanel = DirectCast(lstWizardSteps(intCurrentPosition).Panel, Panel)
    3.             thisPanel.Visible = True
    4.  
    5. 'or
    6.  
    7.             Dim thisPanel As New Panel
    8.             thisPanel = lstWizardSteps(intCurrentPosition).Panel
    9.             thisPanel.Visible = True
    10.  
    11. 'or
    12.  
    13. lstWizardSteps(intCurrentPosition).Panel.Visible = True

    Since then, I have tried setting Modifiers properties of the panels to "Public" and that also didn't make any difference. I also tried adding a Sub to the class to change the property but assuming I did that correctly, it also didn't work. Arrgghh!

    Clearly I'm missing something here, tried for an hour to nut this out to no avail. Any help peoples? Hope so!

    Thanks!
    Scott

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2008
    Posts
    150

    Re: [2008] Can't change Panel visibility?

    Well I finally figured it out. There wasn't really anything 'wrong' with what I was doing (but the combination of small errors did screw me over).

    In the end, I've resolved this by keeping my functions and public variables inside the frmWizard form. I'm still pretty confused but it'll all make sense to me someday, I'm sure!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width