比如我有一个窗体,窗体里面并排放了2个panel
我双击其中一个panel,如何让变化大小?1. 双击充满整个窗体大小? (窗体非全屏状态,就是设计时定义的大小)

解决方案 »

  1.   

    改变
    panel1.Dock
    就可以了啊
      

  2.   

    在哪个事件里写的?
    我双击事件
    panel1_paint事件里写的
    panel1.Dock = DockStyle.Fill结果画面初始进来就已经全屏了,我要的是双击以后全屏
      

  3.   

    panel1_DoubleClick事件里写
    panel1.Dock = DockStyle.Fill
      

  4.   


    有这个事件吗?我在设计模式下双击panel1
    弹出的代码自动就是panel1_Paint事件啊
      

  5.   

    private void panel1_DoubleClick(object sender, System.EventArgs e)
    {}
    设置属性或宽高度
      

  6.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    using System.IO;namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.panel1.DoubleClick+=new EventHandler(panel1_DoubleClick);
            }        void panel1_DoubleClick(object sender, EventArgs e)
            {
                this.panel1.Dock = DockStyle.Fill;
            }    }
    }自已用代码进行绑定来实现.
      

  7.   

    在panel这个控件的事件中找到DoubleClick事件,然后在事件处理函数中写代码如楼上所说
      

  8.   

    楼上太赞了,实现了,万分感谢等一下结贴
    另外,我想问一下
    如果我2个panel是放在一个GroupBox里的
    我现在只想充满GroupBox,那有办法吗?我看DockStyle的属性里没有啊
      

  9.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    using System.IO;namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.panel1.Parent = this.groupBox1;
                this.panel1.DoubleClick+=new EventHandler(panel1_DoubleClick);
            }        void panel1_DoubleClick(object sender, EventArgs e)
            {
                this.panel1.Dock = DockStyle.Fill;
            }    }
    }指定panel1的父控件是groupBox1就可以了.
    panel2可以同样处理.
      

  10.   

    这个好像不对啊
    我添加了 这句 this.panel1.Parent = this.groupBox1;运行出错:
    进行了循环控件引用。控件不能属于自身或成为自身的父级。
      

  11.   


    这个说明panel1已经在groupBox1下面了,没有必要设置。