Hi,
I search informations about insert pictures into an UltraFormattedTextEditor.
What is the best method to add pictures between the text ?
Thanks
Diffy
Ok thanks you very much,
that works good.
David
The EncodeImage property will give you a string that can be used as the value for the 'data' attribute of the img tag. You could do something like:
Image image = this.imageList1.Images[0];string encodedImage = this.ultraFormattedTextEditor1.EditInfo.EncodeImage(image);this.ultraFormattedTextEditor1.EditInfo.InsertValue(String.Format("<img data=\"{0}\" />", encodedImage));
You could certainly build the string value yourself, as I'm mentioned above, instead of inserting the image dynamically.
-Matt
Thanks,
that wokrs and help me thanks. But is there a method to use images stored in an imageList ?
I mean with your solution I need the path and name of the picture, is there a way to use direclty an Image ? like : Image myImage = new Image () and then add the data directly to the FormattedTextEditor ? With ultraFormattedTextEditor1.EditInfo.EncodeImage or ultraFormattedTextEditor1.EditInfo.DecodImage ?
Diffy,
You might find it easiest to use the UITypeEditor at design-time that allows you to edit the value of the text and also show the raw text; you can show this by clicking the '...' next to the Value property in the property grid. There is an icon in the toolbar that will show you a dialog to choose which image you want to show in the editor, after which you can see the new raw text that describes how the image will be shown. While you may not want to use this in your application, it will certainly give you a better illustration of how to achieve certain looks.
With that being said, some sample raw text might look like:
Text <img style="width:12px; height:12px;" src="C:\MyImage.png"/> Image
You could also use the InsertValue method on the EditInfo object to insert formatted text. I believe that this will insert a value at the current cursor location, so you could pass in the formatted image text. You might find the list of supported tags useful.