BaseView.QueryDocument Event
Occurs when the restored layout version has a Document that is not present in the View. Allows you to skip this Document or add it to the View.
Namespace: DevExpress.XtraBars.Docking2010.Views
Assembly: DevExpress.XtraBars.v24.2.dll
Declaration
Event Data
The QueryDocument event's data class is QueryDocumentEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets whether the Document that triggered the QueryDocument event should be restored. |
Caption | Gets or sets the new caption of the restored Document. |
Control | Gets or sets the control hosted by this Document. |
Name | Returns the BaseDocument.ControlName property value of this Document. |
Remarks
You can save and load Document layouts with the View’s SaveLayoutTo...
/ RestoreLayoutFrom...
methods (for example, SaveLayoutToXml and RestoreLayoutFromXml). If a restored layout contains Documents that are not present in the current View, these Documents re-appear and the QueryControl event fires to supply these Documents with content. Document captions are not stored as a part of a layout and are omitted from restored Documents. To set captions for restored Documents, handle the QueryDocument event. Use the e.Name
property to identify a Document that triggered this event (this property returns the Document’s ControlName property value).
void OnQueryDocument(object sender, QueryDocumentEventArgs e) {
if (e.Name == "document1ControlName")
e.Caption = "document1_Restored";
}
void OnQueryControl(object sender, QueryControlEventArgs e) {
if (e.Document == document1)
e.Control = new userControl1();
}
If you do not want the QueryControl
event to supply content for restored Documents, assign controls to the e.Control
property of the QueryDocument
event.
void OnQueryDocument(object sender, QueryDocumentEventArgs e) {
if (e.Name == "document1ControlName") {
e.Caption = "document1_Restored";
e.Control = new userControlPropertiesPanel();
}
}
To skip a Document and not restore it, enable the e.Cancel
property.
void OnQueryDocument(object sender, QueryDocumentEventArgs e) {
if (e.Name == "document2ControlName")
e.Cancel = true;
}