By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Edit menu

P: n/a
I suppose a lot of people have already written an Edit menu (Cut, Copy,
Select all, C/Z, C/Y...) for a text box and other adequate controls. Where
can I find the necessary statements in VB.Net ? Thank you.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Gilbert,

A simple text box Cut, Copy, Paste and Select All in VB.Net would be
something like;

Private Sub mnuCut_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuCut.Click

Clipboard.SetDataObject(TextBox1.SelectedText, True)
TextBox1.SelectedText = ""

End Sub

Private Sub mnuCopy_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuCopy.Click
Clipboard.SetDataObject(TextBox1.SelectedText, True)

End Sub

Private Sub mnuPaste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuPaste.Click

Dim ClipboardData As IDataObject = Clipboard.GetDataObject()
If ClipboardData.GetDataPresent(DataFormats.Text) Then
TextBox1.Text = TextBox1.Text.Insert(TextBox1.SelectionStart,
CType(ClipboardData.GetData(DataFormats.Text), String))
End If

End Sub

Private Sub mnuSelectAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuSelectAll.Click

With TextBox1
.SelectionStart = 0
.SelectionLength = .TextLength
End With

End Sub

Regards,

Gerard O'Donnell (MCSD)

"Gilbert Tordeur" wrote:
I suppose a lot of people have already written an Edit menu (Cut, Copy,
Select all, C/Z, C/Y...) for a text box and other adequate controls. Where
can I find the necessary statements in VB.Net ? Thank you.

Nov 21 '05 #2

P: n/a
* "Gilbert Tordeur" <gi*************@fr.york.com> scripsit:
I suppose a lot of people have already written an Edit menu (Cut, Copy,
Select all, C/Z, C/Y...) for a text box and other adequate controls. Where
can I find the necessary statements in VB.Net ? Thank you.


<URL:http://dotnet.mvps.org/dotnet/samples/controls/downloads/RichTextBoxContext.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.