本文介绍了C#中的DockPanel(Windows应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
任何一个使用DockPanel。我需要帮助。
//代码
Hello friends,
Any One Use DockPanel . I need help on this.
//code
public Form1()
{
InitializeComponent();
DockPanel dockPanel = new DockPanel();
dockPanel.Parent = this;
dockPanel.Dock = DockStyle.Fill;
Controls.Add(dockPanel);
panel2.Parent = dockPanel;
panel1.Parent = dockPanel;
dockPanel.Controls.Add(panel1);
dockPanel.Controls.Add(panel2);
panel1.Dock = DockStyle.Left;
}
推荐答案
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;
using System.Windows;
using WeifenLuo.WinFormsUI;
using WeifenLuo.WinFormsUI.Docking;
using WeifenLuo.WinFormsUI.Docking.Skins;
DockPanel dockPanel1 = new DockPanel();
public Form1()
{
InitializeComponent();
groupBox1.Controls.Add(dockPanel1);
grbMain.Dock = DockStyle.Left;
dockPanel1.Dock = DockStyle.Top;
dockPanel1.Controls.Add(groupBox2);
groupBox2.Dock = DockStyle.Fill;
groupBox2.Controls.Add(dataGridView1);
groupBox2.Controls.Add(richTextBox1);
dataGridView1.Dock = DockStyle.Top;
richTextBox1.Dock = DockStyle.Bottom;
groupBox2.Visible = true;
DockContent content3 = GetDockContentForm("Emails", DockState.DockRight);
content3.Controls.Add(groupBox2);
content3.Show(dockPanel1);
}
private DockContent GetDockContentForm(string name, DockState showHint)
{
DockContent content1 = new DockContent();
content1.Name = name;
content1.TabText = name;
content1.Text = name;
content1.ShowHint = showHint;
return content1;
}
这篇关于C#中的DockPanel(Windows应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!