JayBeeOH

TxtEditor - Set Menu Options Using Timer.

Apr 19th, 2015
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.91 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2015. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   Text Editor
  13. '
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   Feb 2015
  16. '
  17. ' Description:    Simple plain text editor program with printing ability.
  18. '
  19. '                 Documentation is at:
  20. '                   App's screen image is at: http://imgur.com/TzWs9kO
  21. '                   App's screen design time specs at: http://pastebin.com/bhinRQ5d
  22. '                   App's Visual Basic .NET Event Procedures & TODO's is at
  23. '                       http://pastebin.com/UZ4tcEpE
  24. '                   App's Visual Basic .NET code is at http://pastebin.com/u/jaybeeoh
  25. '                   Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
  26. '-------------------------------------------------------------------------------------------
  27.  
  28. #Region " Set Menu Options"
  29.  
  30.     ' Using the timer click event, enable or disable menuItems and toolStripButtons.
  31.     Private Sub Timer1_Tick(sender As Object, e As EventArgs) _
  32.         Handles Timer1.Tick
  33.  
  34.         ' In design time, timer1 was set to ...
  35.         '   Enable = True
  36.         '   Interval = 1500 (or 1.5 seconds).
  37.  
  38.         If MyTextBox.CanUndo Then
  39.             UndoToolStripMenuItem.Enabled = True
  40.         Else
  41.             UndoToolStripMenuItem.Enabled = False
  42.         End If
  43.  
  44.         If MyTextBox.SelectionLength > 0 Then
  45.             CutToolStripMenuItem.Enabled = True
  46.             CutToolStripButton.Enabled = True
  47.             CopyToolStripMenuItem.Enabled = True
  48.             CopyToolStripButton.Enabled = True
  49.             DeleteToolStripMenuItem.Enabled = True
  50.         Else
  51.             CutToolStripMenuItem.Enabled = False
  52.             CutToolStripButton.Enabled = False
  53.             CopyToolStripMenuItem.Enabled = False
  54.             CopyToolStripButton.Enabled = False
  55.             DeleteToolStripMenuItem.Enabled = False
  56.         End If
  57.  
  58.         If String.IsNullOrWhiteSpace(MyTextBox.Text) Then
  59.             SaveToolStripMenuItem.Enabled = False
  60.             SaveAsToolStripMenuItem.Enabled = False
  61.             SaveToolStripButton.Enabled = False
  62.             PrintToolStripMenuItem.Enabled = False
  63.             PrintToolStripButton.Enabled = False
  64.             PrintPreviewToolStripMenuItem.Enabled = False
  65.             FindToolStripMenuItem.Enabled = False
  66.             FindNextToolStripMenuItem.Enabled = False
  67.             ReplaceToolStripMenuItem.Enabled = False
  68.             SelectAllToolStripMenuItem.Enabled = False
  69.         Else
  70.             If MyTextBox.Modified = True Then
  71.                 SaveToolStripMenuItem.Enabled = True
  72.                 SaveToolStripButton.Enabled = True
  73.             End If
  74.             SaveAsToolStripMenuItem.Enabled = True
  75.             PrintToolStripMenuItem.Enabled = True
  76.             PrintToolStripButton.Enabled = True
  77.             PrintPreviewToolStripMenuItem.Enabled = True
  78.             FindToolStripMenuItem.Enabled = True
  79.             ReplaceToolStripMenuItem.Enabled = True
  80.             If findString <> String.Empty Then
  81.                 FindNextToolStripMenuItem.Enabled = True
  82.             Else
  83.                 FindNextToolStripMenuItem.Enabled = False
  84.             End If
  85.             SelectAllToolStripMenuItem.Enabled = True
  86.         End If
  87.     End Sub
  88.  
  89. #End Region
Advertisement
Add Comment
Please, Sign In to add comment