Home All Groups Group Topic Archive Search About

miplementing cut/copy/paste

Author
30 Jan 2006 4:49 PM
guy
VB2005

i need to implement cut/copy/paste as menu options
using th clipboard is ok, that works however how do i find the active
control and assuming it is a text box the portion of text selected?

I can not use Form.ActiveControl as that may be a user control which
contains the active TextBox

the ony way i can see is to iterate through the ActiveControl properties
chaining down until i find a control that makes sense eg textbox, but this
seems very long winded

this must be easy - i just cant see it!

Author
30 Jan 2006 7:06 PM
jvb
guy,

This works in .NET, not I haven't used 2005 yet, but maybe this will
steer you in the right direction.

In the parent menuitem's select event, check what the ActiveControl's
type is then enable your menu selections accordingly.

        Me.mnuEditCut.Enabled = TypeOf Me.ActiveControl Is TextBox
        Me.mnuEditCopy.Enabled = TypeOf Me.ActiveControl Is TextBox
        Me.mnuEditPaste.Enabled = TypeOf Me.ActiveControl Is TextBox

Hope this helps.