Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Misc
Imports Infragistics.Win.FormattedLinkLabel
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
Dim editInfo As FormattedTextEditInfo = Me.UltraFormattedTextEditor1.EditInfo
editInfo.SelectionStart = 0
editInfo.SelectionLength = 0
Dim imagePath As String = "test.bmp"
' Insert an image using 'src' attribute. The formatted text value doesn't actually
' contain the image data. It stores an URL from which it retrieves the image.
' This means that the image must exist at the specified path when the application
' is run. Note that you can specify BaseURL property to specify relative paths
' for images.
editInfo.InsertValue("Referenced Image: <br/> <img src=""" & imagePath + """ width=""50"" height=""50"" /> <br/>")
' Create an Image instance from the file.
Dim img As Image = Image.FromFile(imagePath)
' Encode it into a string that's suitable for embedding in the formatted text.
' Use the EncodeImage method to accomplish that.
Dim imgAsEncodedString As String = editInfo.EncodeImage(img)
' Insert the image with image data embedded inside the formated text. Notice the
' 'data' attribute of 'img' tag. To specify embedded image data, you use the 'data'
' attribute instead of te 'src' attribute.
editInfo.InsertValue("Embedded Image: <br/> <img data=""" & imgAsEncodedString + """ width=""50"" height=""50"" /> <br/>")
' Print out the formatted text value. Notice the embedded image data in the output.
Debug.WriteLine("Formatted Text: " & Me.UltraFormattedTextEditor1.Value.ToString())
' You can use the DecodeImage to decode an image that was encoded using EncodeImage
' method.
Dim decodedImage As Image = editInfo.DecodeImage(imgAsEncodedString)
End Sub