C# winform导航界面..winform 用groupbox,button跟listview

winform利用buttonlistview实现类似QQ设置中的导航菜单

主要利用了DockStyle

具体的代码如下:
注意)尤其要注意控件创建的顺序。
我的控件的创建顺序如下(在.Design.cs中):
            this .groupBox1 = new System .Windows . Forms. GroupBox ();
            this .button1 = new System .Windows . Forms. Button ();
            this .button2 = new System .Windows . Forms. Button ();
            this .button3 = new System .Windows . Forms. Button ();
            this .button4 = new System .Windows . Forms. Button ();
            this .button5 = new System .Windows . Forms. Button ();
            this .button6 = new System .Windows . Forms. Button ();
            this .listView1 = new System .Windows . Forms. ListView ();



主要代码如下:
//用listview跟6个button来实现导航菜单的功|能
private void button1_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button2 . Dock = DockStyle. Bottom;
            button3 . Dock = DockStyle. Bottom;
            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;


            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button2_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button
            listView1 . Dock = DockStyle. None;


            button3 . Dock = DockStyle. Bottom;
            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();


        }


        private void button3_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button4_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button5_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button6_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


        }


        public void ResetButton()          //初始化时的设置
        {


            button1 . Dock = DockStyle. Bottom;
            button2 . Dock = DockStyle. Bottom;
            button3 . Dock = DockStyle. Bottom;
            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;
            listView1 . Dock = DockStyle. Bottom;


            listView1 . Dock = DockStyle. None;
            button1 . Dock = DockStyle. None;
            button2 . Dock = DockStyle. None;
            button3 . Dock = DockStyle. None;
            button4 . Dock = DockStyle. None;
            button5 . Dock = DockStyle. None;
            button6 . Dock = DockStyle. None;


        }


实现的效果如下:



---------------------------------------------------------------------------------------2012年8月30日10:13:50
winform利用buttonlistview实现类似QQ设置中的导航菜单

主要利用了DockStyle

具体的代码如下:
注意)尤其要注意控件创建的顺序。
我的控件的创建顺序如下(在.Design.cs中):
            this .groupBox1 = new System .Windows . Forms. GroupBox ();
            this .button1 = new System .Windows . Forms. Button ();
            this .button2 = new System .Windows . Forms. Button ();
            this .button3 = new System .Windows . Forms. Button ();
            this .button4 = new System .Windows . Forms. Button ();
            this .button5 = new System .Windows . Forms. Button ();
            this .button6 = new System .Windows . Forms. Button ();
            this .listView1 = new System .Windows . Forms. ListView ();



主要代码如下:
//用listview跟6个button来实现导航菜单的功|能
private void button1_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button2 . Dock = DockStyle. Bottom;
            button3 . Dock = DockStyle. Bottom;
            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;


            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button2_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button
            listView1 . Dock = DockStyle. None;


            button3 . Dock = DockStyle. Bottom;
            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();


        }


        private void button3_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button4_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button5_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


            listView1 . Dock = DockStyle. None;


            button6 . Dock = DockStyle. Bottom;




            listView1 . BringToFront();
            listView1 . Dock = DockStyle. Bottom;
            listView1 . Clear();
        }


        private void button6_Click( object sender, EventArgs e)
        {
            ResetButton();  //reset button


        }


        public void ResetButton()          //初始化时的设置
        {


            button1 . Dock = DockStyle. Bottom;
            button2 . Dock = DockStyle. Bottom;
            button3 . Dock = DockStyle. Bottom;
            button4 . Dock = DockStyle. Bottom;
            button5 . Dock = DockStyle. Bottom;
            button6 . Dock = DockStyle. Bottom;
            listView1 . Dock = DockStyle. Bottom;


            listView1 . Dock = DockStyle. None;
            button1 . Dock = DockStyle. None;
            button2 . Dock = DockStyle. None;
            button3 . Dock = DockStyle. None;
            button4 . Dock = DockStyle. None;
            button5 . Dock = DockStyle. None;
            button6 . Dock = DockStyle. None;


        }


实现的效果如下:



---------------------------------------------------------------------------------------2012年8月30日10:13:50
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值