officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentimagecollection-dot-insert-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-system-dot-drawing-dot-image-x29.md
Inserts an image at the specified position in the document.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
[Browsable(false)]
DocumentImage Insert(
DocumentPosition pos,
Image image
)
<Browsable(False)>
Function Insert(
pos As DocumentPosition,
image As Image
) As DocumentImage
| Name | Type | Description |
|---|---|---|
| pos | DocumentPosition |
A DocumentPosition object specifying the position to insert an image.
| | image | Image |
A Image object specifying the image to insert.
|
| Type | Description |
|---|---|
| DocumentImage |
A DocumentImage object specifying the inline image in the document.
|
Document document = server.Document;
DocumentPosition pos = document.Range.Start;
document.Images.Insert(pos, Image.FromFile("Documents\\beverages.png"));
Dim document As Document = server.Document
Dim pos As DocumentPosition = document.Range.Start
document.Images.Insert(pos, Image.FromFile("Documents\beverages.png"))
The following code snippets (auto-collected from DevExpress Examples) contain references to the Insert(DocumentPosition, Image) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Shapes.cs#L84
// Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images[0].Image.NativeImage);
// Resize the image so that its size equals the image in the main document.
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/ShapesActions.cs#L95
// Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images[0].Image.NativeImage);
// Resize the image so that its size equals the image in the main document.
word-document-api-examples/CS/CodeExamples/ShapesActions.cs#L152
// Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images[0].Image.NativeImage);
if (value is DXImage image)
document.Images.Insert(cell.Range.Start, image);
else
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Shapes.vb#L78
' Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images(CInt((0))).Image.NativeImage)
' Resize the image so that its size equals the image in the main document.
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/ShapesActions.vb#L85
' Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images(0).Image.NativeImage)
' Resize the image so that its size equals the image in the main document.
word-document-api-examples/VB/CodeExamples/ShapesActions.vb#L128
' Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images(CInt((0))).Image.NativeImage)
If value.GetType() Is GetType(DXBitmap) Then
document.Images.Insert(cell.Range.Start, CType(value, DXImage))
Else
See Also
InsertFloatingObjectPictureCommand
DocumentImageCollection Interface