Advertisement
Guest User

WiseJ Back Button handler example

a guest
Feb 22nd, 2020
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.44 KB | None | 0 0
  1.     ''' <summary>
  2.     ''' Close the current form.
  3.     ''' </summary>
  4.     ''' <returns>True when a form was found and a close request sent</returns>
  5.     <WebMethod>
  6.     Public Shared Function HitFormBackButtonIfPossible() As Boolean
  7.         Dim intMax As Integer = Application.OpenForms.Count
  8.         If Application.OpenForms(intMax - 1) IsNot Nothing Then
  9.             Dim intCurrentForm As Form = Application.OpenForms(intMax - 1)
  10.  
  11.             'See if this form has a method called RequestFormClose()
  12.             Dim mi As Reflection.MethodInfo = intCurrentForm.GetType().GetMethod("RequestFormClose")
  13.             If mi IsNot Nothing Then
  14.                 'Form has that method. Call it, and let the form handle it.
  15.                 CallByName(intCurrentForm, "RequestFormClose", CallType.Method)
  16.             Else
  17.                 'Form does not contain that method. We will close the form ourselves.
  18.                 intCurrentForm.DialogResult = DialogResult.Cancel
  19.                 intCurrentForm.Close()
  20.             End If
  21.             Return True 'Indicate a close request was sent/handled
  22.         Else
  23.             Return False 'No form found.
  24.         End If
  25.     End Function
  26.  
  27.  
  28. Form Code
  29.         If e.Tool.Name = "btnBack" Then
  30.             RequestFormClose()
  31.         End If
  32.  
  33.  
  34.     Public Sub RequestFormClose()
  35.         SaveIssuesListViewUserSettings()
  36.         'Store last lvIssues results from the criteria selections
  37.         etc....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement