【问题标题】:Return to MainForm if a condition is not set如果未设置条件,则返回 MainForm
【发布时间】:2016-06-15 16:51:37
【问题描述】:

我正在 DevExpress 中编写程序,但偶然发现了一个问题。我想要一个磁贴来显示是否设置了条件,在这种情况下输入一个特定的值。如果用户输入它,他们将转到他们想去的窗口。否则它必须回到主窗体。

如果条件未设置,我遇到的问题是让程序转到主窗体。每当它尝试这样做时,程序就会崩溃。

你能帮帮我吗?谢谢!

Private Sub windowsUIView1_QueryControl(sender As Object, e As QueryControlEventArgs) Handles windowsUIView1.QueryControl
    ....
    ElseIf e.Document Is Document9 Then
        Dim cuentaInicial = InputBox("Por favor introduzca la cuenta inicial del día", "Inicial")

        If cuentaInicial = "" Then
            MsgBox("Por favor introduzca un valor inicial", vbCritical, "Error")
            Me.Refresh()' <-- Problem here
            Exit Sub
        End If

        Try
            Dim inicial As Double = Double.Parse(cuentaInicial)
            e.Control = New Caja
        Catch ex As Exception
            MsgBox(cuentaInicial & ": No es el formato correcto. Favor de verificar", vbCritical, "Error")
            Me.Refresh() '<-- problem here
        End Try
    End If
End Sub

【问题讨论】:

    标签: vb.net forms devexpress controls


    【解决方案1】:

    如果我理解正确,您希望在单击图块时显示一个对话框。如果是这样,我建议您创建句柄 WindowsUIView.TileClick 事件而不是 WindowsUIView.QueryControl 事件(在文档已显示时引发)。

    在 WindowsUIView.TileClick 事件处理程序中,您可以通过在事件参数级别设置 Handled 属性来检查是否可以导航到相应的文档:

    Sub WindowsUIView1_TileClick(sender As Object, e As DevExpress.XtraBars.Docking2010.Views.WindowsUI.TileClickEventArgs) Handles WindowsUIView1.TileClick
        ...
        If e.Document Is Document9 Then
            Dim cuentaInicial = InputBox("Por favor introduzca la cuenta inicial del día", "Inicial")
            If cuentaInicial = "" Then
                MsgBox("Por favor introduzca un valor inicial", vbCritical, "Error")
                e.Handled = True ' !!!do not naviate into the document
                Exit Sub
            End If
        ...
        End If
    End Sub
    

    【讨论】:

    • 这正是我打算做的,它就像一个魅力。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-30
    • 2017-02-15
    • 1970-01-01
    • 2019-08-30
    • 2021-10-18
    • 1970-01-01
    • 2014-05-21
    相关资源
    最近更新 更多