Here is the Code for it....!
Code:
Imports System.Drawing
Imports System.Windows.Forms
public class CopyPasteRichText
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Private Sub frmDragRichText_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim txt As String = "The quick brown fox jumps over the lazy dog."
rchSource.Text = txt
rchSource.Select(txt.IndexOf("quick"), Len("quick"))
rchSource.SelectionFont = New Font(rchSource.SelectionFont, FontStyle.Italic)
rchSource.Select(txt.IndexOf("brown"), Len("brown"))
rchSource.SelectionFont = New Font(rchSource.SelectionFont, FontStyle.Bold)
rchSource.SelectionColor = Color.Brown
rchSource.Select(txt.IndexOf("fox"), Len("fox"))
rchSource.SelectionFont = New Font(rchSource.SelectionFont, FontStyle.Bold)
rchSource.SelectionColor = Color.Red
rchSource.Select(txt.IndexOf("jumps over"), Len("jumps over"))
rchSource.SelectionFont = New Font(rchSource.SelectionFont, FontStyle.Underline)
rchSource.Select(txt.IndexOf("lazy"), Len("lazy"))
rchSource.SelectionFont = New Font(rchSource.SelectionFont, FontStyle.Bold)
rchSource.Select(txt.IndexOf("dog"), Len("dog"))
rchSource.SelectionFont = New Font(rchSource.SelectionFont, FontStyle.Bold)
rchSource.SelectionColor = Color.Blue
rchSource.Select(0, 0)
End Sub
Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
Dim data_object As New DataObject
data_object.SetData(DataFormats.Rtf, rchSource.Rtf)
data_object.SetData(DataFormats.Text, rchSource.Text)
Dim html_text As String
html_text = "<HTML>" & vbCrLf
html_text &= " <HEAD>The Quick Brown Fox</HEAD>" & vbCrLf
html_text &= " <BODY>" & vbCrLf
html_text &= rchSource.Text & vbCrLf
html_text &= " </BODY>" & vbCrLf & "</HTML>"
data_object.SetData(DataFormats.Html, html_text)
Clipboard.SetDataObject(data_object)
End Sub
Bookmarks