marcus_d
asked on
Default Edit Menu Options - Undo, Redo Cut, Copy, Paste etc.
I am writing an application and I want to use the standard edit menu with the standard edit functions (cut, copy paste etc.). Is there a simple way to set up this menu to work the same as the context menu when right clicking on a text box.
Thanks.
Thanks.
no u have to write a code for that.. u have to use clipboard for storing the strings....
ASKER
Do you know of any examples to get me started?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, because my forms are made up of a number of different textboxes, do I have to write individual code for each Textbox?
no, you can get textbox in which the menuitem was pressed like, now it will work for every textbox this contextmeun was attachted to
Private Sub Menu_Copy(sender As System.Object, e As System.EventArgs) handles mnuItem1.click
' Ensure that text is selected in the text box.
If CType(CType(sender, MenuItem).GetContextMenu.S ourceContr ol, TextBox).SelectionLength > 0 Then
' Copy the selected text to the Clipboard.
CType(CType(sender, MenuItem).GetContextMenu.S ourceContr ol, TextBox).Copy()
End If
End Sub
Private Sub Menu_Copy(sender As System.Object, e As System.EventArgs) handles mnuItem1.click
' Ensure that text is selected in the text box.
If CType(CType(sender, MenuItem).GetContextMenu.S
' Copy the selected text to the Clipboard.
CType(CType(sender, MenuItem).GetContextMenu.S
End If
End Sub
ASKER
Thank you, that is exactly what I was looking for allbeit that my textboxes are on a child window. I just replaced the code above with :-
Private Sub m_mCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_mCopy.Click
' Ensure that text is selected in the text box.
If CType(ActiveMdiChild.Activ eControl, TextBox).SelectionLength > 0 Then
'Copy the selected text to the Clipboard
CType(ActiveMdiChild.Activ eControl, TextBox).Copy()
End If
End Sub
One final question. How do I enable/disable the menu options? eg. disable paste option when the clipboard is empty, disable the cut & copy options when no text is selected.
Private Sub m_mCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_mCopy.Click
' Ensure that text is selected in the text box.
If CType(ActiveMdiChild.Activ
'Copy the selected text to the Clipboard
CType(ActiveMdiChild.Activ
End If
End Sub
One final question. How do I enable/disable the menu options? eg. disable paste option when the clipboard is empty, disable the cut & copy options when no text is selected.