title: Editing HTML with a WYSIWYG Editor
body: <p>I have a datagridview with HTML strings. Using a CellDoubleClick event, I am displaying the html string in a WebBrowser control.</p>
  
  <p><strong>In Form1</strong></p>
  
  <pre><code>private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  {
      try
      {
          if (e.ColumnIndex != 0 &amp;&amp; e.RowIndex != -1)
          {
              string s = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
              this.f2 = new Form2(s);
              f2.ShowDialog();
          }
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
  }
  </code></pre>
  
  <p><strong>In Form2</strong></p>
  
  <pre><code>private IHTMLDocument2 doc;
  string reply;
  
  public Form2(string reply)
  {
      InitializeComponent();
      this.reply = reply;
  }
  
  private void Form2_Load(object sender, EventArgs e)
  {
      webBrowser1.DocumentText = reply; &lt;--- string from DataGridView
  
      IHTMLTxtRange range = doc.selection.createRange() as IHTMLTxtRange;
      range.pasteHTML(webBrowser1.DocumentText);
      range.collapse(false);
      range.select();
  
      doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
      doc.designMode = "On";
  }
  </code></pre>
  
  <p>Using the above code, I can successfully display the HTML string as a plaintext, however I am unable to edit it. Alternatively, if I use this code: </p>
  
  <pre><code>private IHTMLDocument2 doc;
  private void Form2_Load(object sender, EventArgs e)
  {
      webBrowser1.DocumentText = reply; &lt;--- string from DataGridView
  
      doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
      doc.designMode = "On";
  
      IHTMLTxtRange range = doc.selection.createRange() as IHTMLTxtRange;
      range.pasteHTML(webBrowser1.DocumentText);
      range.collapse(false);
      range.select();
  }
  </code></pre>
  
  <p>It will be a blank form, but I will be able to write to it.  </p>
  
  <p>I have a feeling it has to do with <code>range.pasteHTML(webBrowser1.DocumentText);</code> being in the Form2_Load method, but I'm unaware of any other method that will allow me to display the HTML string from the DataGridView upon opening Form2. </p>
  
  <p>I want to allow users to be able to edit the HTML string as plaintext (after which it will be converted back to HTML and displayed in the datagridview).</p>