Question

I have a web browser control in C# that it's design mode is on. I use it to make a (WYSIWYG) HTML editor. I want to insert a photo on this without UI, when user wants to insert image I show to him/her a window that shows on it some known name for user. Then with search (s)he find her/his photo and add it to control.

this is my open image form:

Open Image Form

Photos are in database and user only know them with names. I upload all of them in a folder and show above list to user and user selects a picture. I want to add image by it's location in hard disk and allow user to set its alignment .

How I can do this ?

Was it helpful?

Solution

Adding a new element to a document is very logical. The first step is to create the node (element) you wish to append, the next is to find where you wish to append it within the document, and the final step is to actually do the appending.

I write an Example for you:

  private void Form1_Load_1(object sender, EventArgs e)
    {
        webBrowser1.DocumentText = "<html><body></img></body></html>";
    }

    private void insert_image_btn_Click(object sender, EventArgs e)
    {
        HtmlElement userimage = webBrowser1.Document.CreateElement("img");
        userimage.SetAttribute("src", "image location");
        userimage.Id = "imageid";
        webBrowser1.Document.Body.AppendChild(userimage);
    }
    private void btn_set_aliign_Click(object sender, EventArgs e)
    {
        webBrowser1.Document.GetElementById("imageid").SetAttribute("float", "right");
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top