• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • Last Modified:

Hide part of form on load

Hi Experts,
I'm sure one of you can tell me a better way to accomplish what I need, but here is what I am trying to do.  Attached is a screen shot of the form I am currently working with.  What I'm trying to do is hide the bottom half of the form.  As you can see from the screen shot, I have my "Bank Information" and "Name On Check" fields inside a panel.  I only want those fields to show if the user clicks on the "Create New Profile" button.  I can accomplish this by hiding the panel when the form loads, but I don't want a big blank empty space for the bottom half of my window.  I can't find anything on how to hide part of a form, so I'm thinking there is a better way.
Thanks,
Dan
Doc3.doc
0
isda-don
Asked:
isda-don
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
One way is just to grab the bottom of the form and drag it up so the bottom half isn't visible.  When the button is pressed you make the form bigger:

    this.Size = new Size(this.Size.Width, this.Seize.Height + 500); // <-- You need to experiment with what value works best for your form

Of course, you need to use some kind of variable to track whether or not the form is currently "expanded" so you don't try to expand it more.  To collapse the form just do the opposite and subtract the right amount...
0
 
anarki_jimbelCommented:
Code to use can be very simple.
I have a panel anchored to the bottom of a form (and to the sides).
And, for example, a button with the code you may see below:
        bool hidden;
        int panelheight = 184;

        private void button2_Click(object sender, EventArgs e)
        {

            if (!hidden){
                
                hidden = true;
                this.panel1.Height = 0;
                this.Height = this.Height - panelheight;
            }
            else
            {
                this.panel1.Height = panelheight;
                   hidden = false;
                this.Height = this.Height + panelheight;
            }
           
        }

Open in new window

0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now