Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click 'Copy Text from text box and place it in clipboard Clipboard.SetDataObject(CType(ActiveControl, TextBox).SelectedText) End Sub
But i want to be able to copy from a rich text box as well, that where i am having the trouble i know this line below will get text from a rich text box:
Clipboard.SetDataObject(CType(ActiveControl, RichTextBox).SelectedRtf)
but how to i check the form to see if it is trying to copy from a text box or a rich text box i mean something like this ( this not working code or in anyway right it’s just to show you what i mean.
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click 'Copy Text from text box and place it in clipboard If activeControl is a textbox do below Clipboard.SetDataObject(CType(ActiveControl, TextBox).SelectedText) else if activeControl is a Richtextbox do below Clipboard.SetDataObject(CType(ActiveControl, RichTextBox).SelectedRtf) End Sub
i want to be able to check what type of text/rich text box is be use so that i can copy from a text box or a rich text box any help would be great