Pnel控件

分组类控件

面板控件(Panel

分组框控件GroupBox

选项卡控件(TabControl控件

 

Panel 控件是由System.Windows.Forms.Panel类提供的,主要作用就是将其他控件组合在一起放到一个面板,使这些控件更容易管理,当Panel控件面板上要显示过多的控件时,设置AutoScroll属性为true

 

 

Panel控件面板在默认情况下不显示边框,如把BorderStyle属性这是不是None的其他值,就可以适用面板可视化地组合相关的控件

 

主窗体

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 Panel面板控件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Text = "常规";
            button2.Text = "下载";
            button3.Text = "外观";
            button4.Text = "远程下载";
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            hostSet myhost = new hostSet();
            myhost.TopLevel = false;  //没有这一步会提示错误,不能把顶级控件加入到顶级控件中。需要把这个窗体控件的级别改为不是顶级的
            panel1.Controls.Add(myhost);
            myhost.Show();
            myhost.BringToFront();   //将控件置于顶层
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Download mydown = new Download();
            mydown.TopLevel = false;
            this.panel1.Controls.Add(mydown);
            mydown.Show();
            mydown.BringToFront();   //bringToFront 将控件置于顶层  
        }
    }
}

本机设置窗体


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 Panel面板控件
{
    public partial class hostSet : Form
    {
        public hostSet()
        {
            InitializeComponent();
        }

        private void hostSet_Load(object sender, EventArgs e)
        {
            label1.Text = "本机设置";
            checkBox2.Text = "开机远程下载";
            checkBox3.Text = "远程下载关闭监视器";
            this.FormBorderStyle = FormBorderStyle.None;  //设置hostSet窗体的边框为没有边框 是enum枚举类型。
        }
    }
}


下载窗体

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 Panel面板控件
{
    public partial class Download : Form
    {
        public Download()
        {
            InitializeComponent();
        }

        private void Download_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None; //将DownLoad窗体的边框样式选择无边框
            
        }
    }
}

 

  

 

posted @ 2018-03-22 15:48  WhiteSpace  阅读(307)  评论(0编辑  收藏  举报