Introduction to the use of DockPanel (reprint collection)

Source: Internet
Author: User

Reprint 1 Original address: http://www.cnblogs.com/haoxiaobo/archive/2005/03/02/111493.html

This control is good, you can easily achieve such as the VS 2003 in the window positioning, floating, dock, tab, and other interface effects, today has a free download to look at, use up or very easy, probably talk about, save later forget.

There are several classes available in DockPanel, two important, one is DockPanel, the other is dockcontent,

The DockPanel is inherited from the panel and is used to provide a floating dock with a child window to float and dock the site,
The Dockcontent is inherited from the form class and is used to provide a floating window base class. That is to say: Dockcontent objects in the DockPanel object can be any welt, floating, tab and so on.

The process of creating a Docpanel-style program is:

1. Establish a WinForm procedure, citing WinFormsUI.dll;
2. The main window of the program, such as Frmmain; Set the Frmmain.ismdicontainer to true;
3. Put a dockpanel in the frmmain, for example, the name is Panel1, the panel1.dock is set to fill, or the person is the place you plan.
4. Create your Subdocument window class by creating a new Windows FORM that you want to add to your Windows designer. This will be the child window in your program, I've got two of them:
A editbox named Frmchild, with a dock fill in it,
Another called Frmproperty, put a dock fill PropertyGrid, named PropertyGrid1,
It is useful to set these two. Said back.
5. Open the code of Frmchild and Frmproperty to change the class's inherited classes from form to dockcontent;
such as: public class FrmChild:WeifenLuo.WinFormsUI.DockContent//Note this is changed!
{

}


6. Add two private members to the Frmmain:
Frmchild FC;
Frmproperty FP;
These two members are used to hold pointers to the two windows that are created later.
7. Write some code for Frmmain's load, as follows: FC = new Frmchild ();
fp = new Frmproperty ();
Fc. Show (this. dockPanel1);
Fp. Show (this. dockPanel1);
Fp.propertyGrid1.SelectedObject = FC;
Fp.propertyGrid1.PropertyValueChanged + = new Propertyvaluechangedeventhandler (propertygrid1_propertyvaluechanged) ;

Fc. MouseDown + = new MouseEventHandler (Fc_mousedown);
Fc. MouseUp + = new MouseEventHandler (fc_mouseup);

is to create two windows, these two windows are inherited from the dockcontent, there are welt, tab, automatic hide ability, very interesting.
Note that Dockcontent has a new show () method, you can specify the DockPanel to show, of course, write the dockPanel1 you prepared;
All two show, and then for FP's propertyGrid1 specify the object to display, is FC;
And then register the event handler, these are in order to be able to realize the property changed window, the window changed the effect of property change, you can dynamically see the properties of these objects for its appearance and shape for the impact, for only want to build a multiple window program, show finished on it.
8. Due to the events registered above, add a few event handlers: private void Propertygrid1_propertyvaluechanged (object s, Propertyvaluechangedeventarg S e)
{

This.dockPanel1.Invalidate ();
This.fc.Invalidate ();
This.fc.Refresh ();

}

private void Fc_mousedown (object sender, MouseEventArgs e)
{
This.fp.propertyGrid1.Refresh ();
}

private void Fc_mouseup (object sender, MouseEventArgs e)
{
This.fp.propertyGrid1.Refresh ();
}


Run it, see how it works? You put these two windows on the edge, here is a try, very interesting.
You can also use this program to try the effects of dockcontent properties.

Almost forget, here is the download address of this thing, have the source code, very good! It's just that the speed is too slow from me.

http://sourceforge.net/projects/dockpanelsuite/

Reprint 2 Original address: http://hjqtommy.blogbus.com/logs/27552950.html

Copyright notice: When reprinted, please indicate the original source and author information of the article by hyperlink form and this statement
http://hjqtommy.blogbus.com/logs/27552950.html 1.DockPanel Suite Quick Start
(1) Create a form that inherits from Dockcontent
public partial class Equipmenttreewindow:dockcontent and then slightly set some properties such as showhint (docking position) and so on.
(2) Declares that a main form contains a DockPanel. You can simply drag the control directly
Private WeifenLuo.WinFormsUI.Docking.DockPanel DockPanel; Set up Documentstyle and so on.
(3) Private Equipmenttreewindow Equipwin = new Equipmenttreewindow (); Life and instantiate a control you just created and display it in DockPanel
Equipwin.show (DockPanel); Then run it and you'll see the effect.


2. In use. NET open source Framework DockPanel suite, you often need to put two panels on the same side but do not need to appear tab, then you can do this
Move Scanwin to the lower half of the left
Scanwin.show (DockPanel, Dockstate.dockbottom);
Scanwin.show (DockPanel, dockstate.dockleft); Scanwin is a form that inherits the Dockcontent, so that you can put Scanwin on the lower part of the left without the tab. The upper half of this time can be called directly. Show (Dockpanel,dockstate.dockleft) without having to call two times layout like Scanwin.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.