Julio Garcia Julio Garcia - 5 months ago 23
Vb.net Question

Return to MainForm if a condition is not set

I am writing a program in DevExpress and I have stumbled upon a problem. I want one tile to show if a condition is set, in this case input a specific value. If the user inputs it they will go to the window they want to go. Otherwise it will have to go back to the main form.

The problem I am experiencing is getting the program to go to the main form if the condition is not set. Whenever it tries to do that the program crashes.

Can you please help me? Thanks!

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

Answer

If I understand you correctly, you wish to show a dialog on clicking a tile. If so, I suggest that you create handle the WindowsUIView.TileClick event instead of WindowsUIView.QueryControl event(raised when the document is already shown).

Within the WindowsUIView.TileClick event handler you can check whether or no you can navigate into the corresponding document via setting the Handled property at event arguments level:

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