Editor for WinForms | ComponentOne
In This Topic
    Insert Image
    In This Topic

    You can insert images at the cursor location in the document using InsertImageAtSelectionAsync method of the C1Editor class. This method accepts the source path of the image as parameter. The following code inserts the "C1.png" image from the 'Resources' folder in the sample into the document at the location of the cursor.

    C#
    Copy Code
    c1Editor1.InsertImageAtSelectionAsync(Image.FromFile(@"Resources/C1.png"));

    The image below is output of the above code snippet.

    inserted image through the code

    Besides this, you can also insert an image in the document through the EditorRibbon by using the Insert Image option in Insert group. This opens an Image dialog box which provides multiple options like rotate, resize, preserve aspect ratio of the image, and more.

    Screenshot for inserting image using button

    To edit an exisitng image in the document, follow these steps:

    1. Select the image.
    2. Click Insert Image option from the Insert group of EditorRibbon to open the Image dialog box for editing the image.
    3. Click the Save button.
    OR
    1. Right-click on the image, choose the Edit image option from the context menu as shown in the following image to open the Image dialog box for editing.
    2. Click the Save button.

    Edit existing image through context menu