1

I am using “Microsoft Visual Studio 2010” and C# language. My user interface look like this(before user click the Advance button): enter image description here

If user click Advance button, I want it to show the rest of the window as shown in the picture bellow:

enter image description here

Can you please tell me how can have all these information hidden till the user click the Advance button? How can I have a smaller window first, as shown in the first figure. And when the user press the advance button, it will expand and show the rest. If you can show me with details, I would really appreciate it

4

5 回答 5

3
于 2013-04-24T05:31:38.073 回答
2

1.在表单底部添加一个面板,并添加您需要在高级按钮单击中显示的所有控件。

2.更改面板和表单的以下属性,

   > AutoSize  >> true
   > AutoSizeMode  >> GrowAndShrink

3.然后在表单加载事件中,您可以使用如下

private void Form1_Load(object sender, EventArgs e)
{
    panel1.Visible = false;
}

4.然后在高级按钮点击事件

private void button1_Click_1(object sender, EventArgs e)
{
     //panel1.Visible = true;
        string value1 = button1.Text;
        switch(value1)
        {
            case "Expand":
                panel1.Visible = true;
                break;
            case "Reduce":
                panel1.Visible = false;
                break;
        }
        button1.Text = "Reduce";
        if(panel1.Visible==true)
        {
            button1.Text = "Reduce";
        }
        else if(panel1.Visible==false)
        {
            button1.Text = "Expand";
        }     
}
于 2015-06-24T01:10:55.923 回答
1

第一个表单的 OnLoad 事件将每个控件或组框(无论您使用的是哪个)可见性设置为 false。

并在高级按钮单击事件上使其可见性为真。

代码如下:

private void FirstForm_Load(object sender, EventArgs e)
{
  controlName.Visible=false;
}

 private void btnAdvance_Click(object sender, EventArgs e)
 {
     controlName.Visible=true;
 }

可见性属性的 MSDN:

http://msdn.microsoft.com/en-IN/library/system.windows.uielement.visibility.aspx

希望它有帮助。

于 2013-04-24T05:06:46.263 回答
1

首先将以下属性设置为可见 false,如所有 lebels 和文本框。然后在高级按钮的点击事件中设置所有可见的属性为真。

于 2013-04-24T05:09:05.770 回答
0

你可以简单地这样做,

1.在表单底部添加一个面板,并添加您需要在高级按钮单击中显示的所有控件。

2.更改面板和表单的以下属性,

       > AutoSize  >> true
       > AutoSizeMode  >> GrowAndShrink

3.然后在表单加载事件中,您可以使用如下

    private void Form1_Load(object sender, EventArgs e)
    {
        panel1.Visible = false;
    }

4.然后在高级按钮点击事件

    private void button1_Click_1(object sender, EventArgs e)
    {
        panel1.Visible = true;      
    }

希望这会帮助你和任何其他需要这个的人......!

于 2014-05-06T04:35:32.117 回答