Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement a "click-here-to-expand" container

I have no better way of explaining it, but I want to implement a container that only is shown after the user clicked "Advanced" or a plus sign somewhere in the dialog. I have a login form and want to add some "Advanced" settings. But they should normally out of view.

Of course, the dialog has to resize nicely to hold the extended content.

How should I go to implement such a thing. I have tried some Google searches, but can't find the right search words. Windows doesn't seem to have it by default.

like image 909
Bart Friederichs Avatar asked Feb 13 '13 14:02

Bart Friederichs


Video Answer


1 Answers

as John Willemse suggested, I ended up creating the functionality myself. I added a Panel in the form that I just set visible or invisible.

In the Form's constructor (to hide it on first view):

    public FrmLogin() {
        InitializeComponent();

        pnlAdvanced.Visible = false;
        Height -= pnlAdvanced.Height;
    }

Then, I added a LinkLabel with this Clicked handler:

   private void linkLabel1_LinkClicked(object sender, 
                            LinkLabelLinkClickedEventArgs e) {
        if (pnlAdvanced.Visible == false) {
            Height += pnlAdvanced.Height;
            pnlAdvanced.Visible = true;
        } else {
            Height -= pnlAdvanced.Height;
            pnlAdvanced.Visible = false;
        }
    }

Works perfectly and no extra code needed.

like image 69
Bart Friederichs Avatar answered Sep 27 '22 17:09

Bart Friederichs