3 Replies - 4480 Views - Last Post: 22 August 2009 - 02:54 AM Rate Topic: -----

#1 FallenDreamL7   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-August 09

[VB.Net] How can I copy all the text from a RichTextBox?

Post icon  Posted 21 August 2009 - 09:53 PM

Hello,
Just a straight forward question.
How can I copy all the text within a RichTextBox so that I could paste it somewhere else? I am not sure how I could do this in VB.Net

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnd.Click

		RichTextBox1.Copy()

	End Sub



I tried coding it like that, however that code doesn't do anything. Can anyone please show me the correct way?
Thank you for your attention.

Is This A Good Question/Topic? 0
  • +

Replies To: [VB.Net] How can I copy all the text from a RichTextBox?

#2 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 783
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: [VB.Net] How can I copy all the text from a RichTextBox?

Posted 21 August 2009 - 11:51 PM

You can use Clipboard.SetText(RichTextBox1.Text) to copy the text from the RichTextBox control and then use Clipboard.GetText() to get the text.
Was This Post Helpful? 1
  • +
  • -

#3 FallenDreamL7   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-August 09

Re: [VB.Net] How can I copy all the text from a RichTextBox?

Posted 22 August 2009 - 02:04 AM

It seems that the code only works for certain events, but yes it works fine.

Thank you very much for your help.

This post has been edited by FallenDreamL7: 22 August 2009 - 02:19 AM

Was This Post Helpful? 0
  • +
  • -

#4 Jay93   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 93
  • Joined: 04-August 09

Re: [VB.Net] How can I copy all the text from a RichTextBox?

Posted 22 August 2009 - 02:54 AM

You could also use:
RichTextBox1.SelectAll()
RichTextBox1.Copy()


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1