Back to Devexpress

DocumentImageCollection.Insert(DocumentPosition, Image) Method

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

latest7.2 KB
Original Source

DocumentImageCollection.Insert(DocumentPosition, Image) Method

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

Declaration

csharp
[Browsable(false)]
DocumentImage Insert(
    DocumentPosition pos,
    Image image
)
vb
<Browsable(False)>
Function Insert(
    pos As DocumentPosition,
    image As Image
) As DocumentImage

Parameters

NameTypeDescription
posDocumentPosition

A DocumentPosition object specifying the position to insert an image.

| | image | Image |

A Image object specifying the image to insert.

|

Returns

TypeDescription
DocumentImage

A DocumentImage object specifying the inline image in the document.

|

Remarks

csharp
Document document = server.Document;
DocumentPosition pos = document.Range.Start;
document.Images.Insert(pos, Image.FromFile("Documents\\beverages.png"));
vb
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

csharp
// 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

csharp
// 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

csharp
// Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images[0].Image.NativeImage);

spreadsheet-document-api-use-worksheet-table-as-data-source/CS/SpreadsheetDocumentServerAsDataSourceExample/Form1.cs#L110

csharp
if (value is DXImage image)
    document.Images.Insert(cell.Range.Start, image);
else

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Shapes.vb#L78

vb
' 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

vb
' 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

vb
' Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images(CInt((0))).Image.NativeImage)

spreadsheet-document-api-use-worksheet-table-as-data-source/VB/SpreadsheetDocumentServerAsDataSourceExample/Form1.vb#L95

vb
If value.GetType() Is GetType(DXBitmap) Then
    document.Images.Insert(cell.Range.Start, CType(value, DXImage))
Else

See Also

InsertPicture

InsertPictureCommand

InsertFloatingObjectPictureCommand

DocumentImageSource

DocumentImageCollection Interface

DocumentImageCollection Members

DevExpress.XtraRichEdit.API.Native Namespace