windowsforms-devexpress-dot-xtrabars-dot-docking2010-dot-views-dot-baseview-a5398f48.md
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.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public event QueryDocumentEventHandler QueryDocument
Public Event QueryDocument As QueryDocumentEventHandler
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. |
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();
}
Private Sub OnQueryDocument(ByVal sender As Object, ByVal e As QueryDocumentEventArgs)
If e.Name = "document1ControlName" Then
e.Caption = "document1_Restored"
End If
End Sub
Private Sub OnQueryControl(ByVal sender As Object, ByVal e As QueryControlEventArgs)
If e.Document = document1 Then
e.Control = New userControl1()
End If
End Sub
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();
}
}
Private Sub OnQueryDocument(ByVal sender As Object, ByVal e As QueryDocumentEventArgs)
If e.Name = "document1ControlName" Then
e.Caption = "document1_Restored"
e.Control = New userControlPropertiesPanel()
End If
End Sub
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;
}
Private Sub OnQueryDocument(ByVal sender As Object, ByVal e As QueryDocumentEventArgs)
If e.Name = "document2ControlName" Then
e.Cancel = True
End If
End Sub
See Also