CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2011
    Posts
    44

    [RESOLVED] Hiding/Unhiding txt boxes on a form

    I have a combo box on my form, that has 2 options to select from. When my form loads, under the form_Load() Event I have numerous text boxes set to ...Visible = False; Depending upon what selection is chosen within that combo box, I want specific text boxes to become viewable.

    I.E. If comboboxAnswer = Tester1
    {
    ...Visible = True;
    ...Visible = True;
    }

    But I don't know where these lines of code would need to go that would let those text boxes be visible.

    Code:
    Private Void Form_Load()
    
                txtAirlineName.Visible = false;
                txtNumberofPassengers.Visible = false;
                txtFlightNumber.Visible = false;
                txtFighterType.Visible = false;
                lblPassengerPlaneData.Visible = false;
                lblAirlineName.Visible = false;
                lblNumberofPassengers.Visible = false;
                lblFlightNumber.Visible = false;
                lblFighterJetPlaneType.Visible = false;
                lblFighterType.Visible = false;
    
                cboAA.Items.Add("Test1");
                cboAA.Items.Add("Test2");
    Last edited by jo15765; August 13th, 2011 at 07:43 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Hiding/Unhiding txt boxes on a form

    Look at the combo boxes selected index changed event
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    May 2011
    Posts
    44

    Re: Hiding/Unhiding txt boxes on a form

    Great, now my next ? is. I have a Create button on the form, that runs some code, and in will display the results. If once the results are displayed, I decide to change from Test1 to Test2, how can I then tell the form to hide the text boxes that belong to Test1 and only display the textboxes that belong to Test2?
    Last edited by jo15765; August 13th, 2011 at 09:00 PM.

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Hiding/Unhiding txt boxes on a form

    Set the visible property to false at whatever time you want the box to be hidden and to true when you want it shown.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    May 2011
    Posts
    44

    Re: Hiding/Unhiding txt boxes on a form

    Of course, something so simple. Thanks!

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

Featured