User Interface for .NET / User's Guide / Docking Panels / Document Model / Document Manager

Document Manager
 Overview
The top-level manager of all documents registered with the framework is the NDocumentManager. This object is responsible for registering documents, firing document related events, keeping track of the currently active document, etc.
 Adding Documents

The following code demonstrates how to add documents to the document view: 

C#
Copy Code
NDocumentManager manager = this.nDockManager1.DocumentManager;
//create a uidocument instance NUIDocument
doc = new NUIDocument();
doc.Text = "My Document";
doc.Client = new TextBox();
//add the document to the current document view (which is TabbedMdi by default)
manager.AddDocument(doc);

Visual Basic
Copy Code
Dim manager As NDocumentManager = Me.nDockManager1.DocumentManager
'create a uidocument instance NUIDocument
doc = New NUIDocument()
doc.Text = "My Document"
doc.Client = New TextBox()
'add the document to the current document view (which is TabbedMdi by default)
manager.AddDocument(doc)

You have complete control over the adding process. The AddDocument method has 4 different overloads via which you may select the parent zone, DockStyle and index of insertion. 

The three overloads with additional parameters are valid when the current document view style is MdiTabbed.
 DocumentManager Events

The following table describes events fired by the NDocumentManager instance:

 

Method Description

 ActiveDocumentChanged

Fired when the currently active document has changed.

 DocumentActivated

Fired whenever a document has been activated. Note that a document might be activated multiple times.

 DocumentClosed

Fired when a document has been closed and removed from the view.

 DocumentClosing

Fired when a document is about to be closed. Cancelable.

 DocumentInserted

Fired when a document has been inserted.

 DocumentInserting

Fired when a document is about to be inserted. Cancelable.

 DocumentViewStyleChanged

Fired when the current document view style has changed.

 DocumentBeginDrag

Fired when the current document drag operation just started.

 DocumentEndDrag

Fired when the current document drag operation ends.

 

The NDocumentManager exposes lots of events among which are the DocumentActivated and ActiveDocumentChanged ones. The first event is fired whenever a document is activated while the second one is fired when the current active document changes. 

 Document Style

The object which controls documents appearance as well as document view style, document strips, etc. is the NDocumentStyle, member of the NDocumentManager.

 

The following code demonstrates how to change the appearance of the document view:

C#
Copy Code
NDocumentStyle style = this.nDockManager1.DocumentStyle;
style.TabAlign = TabAlign.Bottom;
style.TabStyle = TabStyle.MultiDocument;
style.StripButtons = DocumentStripButtons.VS2003;
Visual Basic
Copy Code
Dim style As NDocumentStyle = Me.nDockManager1.DocumentStyle
style.TabAlign = TabAlign.Bottom
style.TabStyle = TabStyle.MultiDocument
style.StripButtons = DocumentStripButtons.VS2003

 

 Built-in Editor

The NDocumentManager comes with a built-in editor which allows you to visually activate, close, tile, etc. documents.

 

The following code demonstrates how to display the editor:

 

C#
Copy Code
this.nDockManager1.DocumentManager.ShowDocumentsEditor();

Visual Basic
Copy Code
Me.nDockManager1.DocumentManager.ShowDocumentsEditor()

 

See Also