c#QueryControlEventArgs
时间: 2023-12-05 19:41:35 浏览: 36
`QueryControlEventArgs`是DevExpress WinForms控件库中的一个类,用于处理Windows UI视图中的控件查询事件。当Windows UI视图需要显示一个文档时,它会引发`QueryControl`事件,该事件将`QueryControlEventArgs`对象作为参数传递。在事件处理程序中,可以使用`QueryControlEventArgs`对象的`Document`属性来确定要显示哪个文档,并使用`Control`属性来指定要显示的控件。以下是C#和VB.NET中使用`QueryControlEventArgs`的示例代码:
C#:
```csharp
void windowsUIView1_QueryControl(object sender, DevExpress.XtraBars.Docking2010.Views.QueryControlEventArgs e)
{
if (e.Document == ucSample1Document)
e.Control = new WinModernUI.ucSample1();
if (e.Document == ucSample2Document)
e.Control = new WinModernUI.ucSample2();
// . . .
if (e.Control == null)
e.Control = new System.Windows.Forms.Control();
}
```
VB.NET:
```vb.net
Private Sub windowsUIView1_QueryControl(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking2010.Views.QueryControlEventArgs)
If e.Document = ucSample1Document Then
e.Control = New WinModernUI.ucSample1()
End If
If e.Document = ucSample2Document Then
e.Control = New WinModernUI.ucSample2()
End If
' . . .
If e.Control Is Nothing Then
e.Control = New System.Windows.Forms.Control()
End If
End Sub
```