布局过程:

1.Form1:

 

Form1

//主板
2.panel1:

 

 

Form1
panel1Anchor = Top,Bottom,Left,Right

3.panel2,panel3

 

panel1
panel2Dock = Top
panel3

Dock = Fill

AutoScroll = TRUE

 

4.pnlTop

 

panel2
pnlTopDock = Left
5.pnlMin,pnlMax

 

pnlTop
pnlMax

//最好有个BackgroundImage

visible = FALSE

pnlMin

//最好有个BackgroundImage

Anchor = Bottom,Left

visible = TRUE

 


最后,大概这个样子:


分别给pnlMin和pnlMax添加Click事件:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    
public partial class Form1 : Form
    {
        
private int maxHeightSize = 0;

        
public Form1()
        {
            InitializeComponent();
            maxHeightSize 
= panel2.Height;
        }

        
private void pnlMax_Click(object sender, EventArgs e)
        {
            panel2.Height 
= maxHeightSize;
            pnlMax.Visible 
= false;
            pnlMin.Visible 
= true;
        }

        
private void pnlMin_Click(object sender, EventArgs e)
        {
            panel2.Height 
= pnlMin.Height;
            pnlMax.Visible 
= true;
            pnlMin.Visible 
= false;
        }
    }
}


演示效果:


------------------------------------------------------------------------------------end












posted on 2011-06-10 11:43 Ying-er 阅读(1508) 评论(0)  编辑  收藏 所属分类: .Net

只有注册用户登录后才能发表评论。


网站导航: