Hello world of DaniWeb. If the title of this thread kinda looks complicated, believe me, it's not. This'll be a simple and straightforward question along with a piece of code attached to it. So, how can I determine whether a RichTextBox control contains text or not when functions such as Cut, Clear etc. are used? You'll first notice the Clipboard check, which I got to work. It basically checks whether text is saved on the Clipboard. Just don't worry about that. What I would like to make work is the feature to enable/disable options such as "Cut" and "Clear" when no text is in the RichTextBox control. Hope you know what I mean. Please, I repeat, take a look at the code I wrote myself which apparently doesn't work right (that's why I'm posting on here after all). Thank you in advance.
Private Sub FunctionCheck()
If Clipboard.ContainsText Then
PasteToolStripMenuItem.Enabled = True
ToolStripButton5.Enabled = True
PasteToolStripMenuItem1.Enabled = True
End If
If RichTextBox1.Text Is "" Then
UndoToolStripMenuItem.Enabled = False
CutToolStripMenuItem.Enabled = False
CopyToolStripMenuItem.Enabled = False
DeleteToolStripMenuItem.Enabled = False
FindToolStripMenuItem.Enabled = False
ReplaceToolStripMenuItem.Enabled = False
SelectAllToolStripMenuItem.Enabled = False
ToolStripMenuItem2.Enabled = False
ReadSelectedTextToolStripMenuItem.Enabled = False
ToolStripButton1.Enabled = False
ToolStripButton3.Enabled = False
ToolStripButton4.Enabled = False
ToolStripButton6.Enabled = False
ToolStripButton11.Enabled = False
ToolStripButton12.Enabled = False
ToolStripDropDownButton1.Enabled = False
UndoToolStripMenuItem1.Enabled = False
CutToolStripMenuItem1.Enabled = False
CopyToolStripMenuItem1.Enabled = False
DeleteToolStripMenuItem1.Enabled = False
SelectAllToolStripMenuItem1.Enabled = False
DeselectAllToolStripMenuItem.Enabled = False
ReadSelectedTextToolStripMenuItem1.Enabled = False
ElseIf RichTextBox1.Text IsNot "" Then
UndoToolStripMenuItem.Enabled = True
CutToolStripMenuItem.Enabled = True
CopyToolStripMenuItem.Enabled = True
DeleteToolStripMenuItem.Enabled = True
FindToolStripMenuItem.Enabled = True
ReplaceToolStripMenuItem.Enabled = True
SelectAllToolStripMenuItem.Enabled = True
ToolStripMenuItem2.Enabled = True
ReadSelectedTextToolStripMenuItem.Enabled = True
ToolStripButton1.Enabled = True
ToolStripButton3.Enabled = True
ToolStripButton4.Enabled = True
ToolStripButton6.Enabled = True
ToolStripButton11.Enabled = True
ToolStripButton12.Enabled = True
ToolStripDropDownButton1.Enabled = True
UndoToolStripMenuItem1.Enabled = True
CutToolStripMenuItem1.Enabled = True
CopyToolStripMenuItem1.Enabled = True
DeleteToolStripMenuItem1.Enabled = True
SelectAllToolStripMenuItem1.Enabled = True
DeselectAllToolStripMenuItem.Enabled = True
ReadSelectedTextToolStripMenuItem1.Enabled = True
End If
End Sub