How to: Insert a Picture
The RichEditControl supports the following graphic types:
- Bitmap (*.bmp, *.dib)
- JPEG File Interchange Format (*.jpg, *.jpeg)
- Portable Network Graphics (*.png)
- Graphics Interchange Format (*.gif)
- Tagged Image Format (*.tif, *.tiff)
- Microsoft Enhanced Metafile (*.emf)
- Windows Metafile (*.wmf)
Use the following API to place an image in the document:
API | Description |
---|---|
Appends an image. | |
Inserts an image in the specified position. |
The code sample belows inserts an image at the document’s start.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-richedit-document-api-e5219
DocumentPosition pos = document.Range.Start;
document.Images.Insert(pos, DocumentImageSource.FromFile("beverages.png"));
The created DocumentImage object is added to two collections: ShapeCollection and DocumentImageCollection The object’s Shape.TextWrapping property will be set to TextWrappingType.InLineWithText
The code sample below inserts an image in the specified position. The resulting object is added to the ShapeCollection only.