Has anyone done any code for the Cut, Copy, and Paste events on the menuStrip? If so, can you please share it with the group?
Which menustrip ? Infragistics or MS ?
I presume it's the MS menustrip with the "standard" options added (File, Copy etc)
What are you wanting to do ? Copy & paste text ?
It's the menu strip that's created when you create a new ABL MIDI form. I just want to be able to select text in any ultraTextEditor control, press ctrl-C, and have the text available on the clipboard. The designer stubs in the following code.
METHOD PRIVATE VOID CopyToolStripMenuItem_Click(sender AS System.Object, e AS System.EventArgs):
/* TODO: Use System.Windows.Forms.Clipboard to insert the selected text or images into the clipboard */
END.
try
CAST(THIS-OBJECT:ActiveControl,System.Windows.Forms.TextBox):Copy().
to copy
and this
THIS-OBJECT:ActiveControl:Text = System.Windows.Forms.Clipboard:GetText().
to paste
oh, dammit, I just saw that you are using the ultraTextEditor. Change the cast from
System.Windows.Forms.TextBox
to
Infragistics.Win.UltraWinEditors.UltraTextEditor
and it should then work for you
Works great. Thanks!
yay! my first help on .net !
The System.Windows.Forms.TextBox version works fine with ultraTextEditors too.
oh, ok
heh my ultra cast didn't work. I'll find a fix for that as well.
Is there an easy way to only execute those lines in text editors? It blows up if I do control-C in an ultraDateTimeEditor. It would be nice to make it work with that control too, but ignore things like buttons.
As as basic test:
If Type-Of(THIS-OBJECT:ActiveControl,System.Windows.Forms.TextBox) THEN
CAST(THIS-OBJECT:ActiveControl,System.Windows.Forms.TextBox):Copy().
and
If Type-Of(THIS-OBJECT:ActiveControl,System.Windows.Forms.TextBox) THEN
THIS-OBJECT:ActiveControl:Text = System.Windows.Forms.Clipboard:GetText().
You should also look at the documention of System.Windows.Forms.Clipboard for more info - you can copy and paste images, spreadsheets etc etc
maybe this works because maybe the ultraedittext box has subclassed / inherited / whatever the standard ms textbox ...
Thanks again for your help. The only problem is paste() overlays the entire contents of the editor, instead of just pasting it in at the position of the cursor. I'll look at the doc to see if I can find a solution.
in the paste trigger, use
CAST(THIS-OBJECT:ActiveControl,System.Windows.Forms.TextBox):Paste()
Bingo. Thanks!
heh. Right, that's it. I'm off to catch some zzzz's. I'll Be back tomorrow!