Link to home
Start Free TrialLog in
Avatar of marcus_d
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.
Avatar of r_a_j_e_s_h
r_a_j_e_s_h

no u have to write a code for that.. u have to use clipboard for storing the strings....
Avatar of marcus_d

ASKER

Do you know of any examples to get me started?
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.SourceControl, TextBox).SelectionLength > 0 Then
            ' Copy the selected text to the Clipboard.
            CType(CType(sender, MenuItem).GetContextMenu.SourceControl, TextBox).Copy()
        End If
    End Sub
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.ActiveControl, TextBox).SelectionLength > 0 Then
            'Copy the selected text to the Clipboard
            CType(ActiveMdiChild.ActiveControl, 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.