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; } } }自已用代码进行绑定来实现.
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可以同样处理.
panel1.Dock
就可以了啊
我双击事件
panel1_paint事件里写的
panel1.Dock = DockStyle.Fill结果画面初始进来就已经全屏了,我要的是双击以后全屏
panel1.Dock = DockStyle.Fill
有这个事件吗?我在设计模式下双击panel1
弹出的代码自动就是panel1_Paint事件啊
{}
设置属性或宽高度
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;
} }
}自已用代码进行绑定来实现.
另外,我想问一下
如果我2个panel是放在一个GroupBox里的
我现在只想充满GroupBox,那有办法吗?我看DockStyle的属性里没有啊
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可以同样处理.
我添加了 这句 this.panel1.Parent = this.groupBox1;运行出错:
进行了循环控件引用。控件不能属于自身或成为自身的父级。
这个说明panel1已经在groupBox1下面了,没有必要设置。