ArcObjects Library Reference

Fade Windows Form Closed Snippet

Cause a System.Windows.Form to close in a faded way.

[C#]

///<summary>Cause a System.Windows.Form to close in a faded way.</summary>
/// 
///<param name="myForm">A System.Windows.Form object</param>
///  
///<remarks>This will cause the form to close by making it seem to disappear gradually.</remarks>
public void FadeWindowsFormClosed(System.Windows.Forms.Form myForm)
{
  for (System.Int32 i = 10; i >= 0; i--)
  {
    myForm.Opacity = myForm.Opacity - 0.1;
    System.Windows.Forms.Application.DoEvents();
    System.Threading.Thread.Sleep(100);
    i = i - 1;
  }
  myForm.Close();
}
[Visual Basic .NET]

'''<summary>Cause a System.Windows.Form to close in a faded way.</summary>
''' 
'''<param name="myForm">A System.Windows.Form object</param>
'''  
'''<remarks>This will cause the form to close by making it seem to disappear gradually.</remarks>
Public Sub FadeWindowsFormClosed(ByVal myForm As System.Windows.Forms.Form)

  Dim i As System.Int32
  For i = 10 To 0 Step -1
    myForm.Opacity = myForm.Opacity - 0.1
    System.Windows.Forms.Application.DoEvents()
    System.Threading.Thread.Sleep(100)
    i = i - 1
  Next
  myForm.Close()

End Sub


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • System
  • System.Windows.Forms