Using Visio Drawing Control 2003 with System.Windows.Forms.RichTextBox
-
I'm having difficulty using the Visio Drawing Control 2003 and the RichTextBox anywhere in the same application. e.g.
public partial class VisForm : Form { public VisForm() { //RichTextBox rttb = new RichTextBox(); //string rtf = rttb.Rtf; //rttb.SelectedRtf = @"{\rtf1\ansi " + "Visible" + @"{\v " + "Hidden" + @"}}"; //string rtfText = rttb.Text; InitializeComponent(); RichTextBox rttb1 = new RichTextBox(); string rtf1 = rttb1.Rtf; rttb1.SelectedRtf = @"{\rtf1\ansi " + "Visible" + @"{\v " + "Hidden" + @"}}"; string rtfText1 = rttb1.Text; } --- }
First Scenario: Initialize the RichTextBox BEFORE the Visio Drawing Control. Set rttb.SelectedRtf = @"{\rtf1\ansi " + "Visible" + @"{\v " + "Hidden" + @"}}"; rttb.Text will then be "VisibleHidden" which is correct. With the form displayed press CTRL+F to display the Find Dialog. The result is an AccessViolationException with the following message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt". Second Scenario: Initialize the RichTextBox AFTER the Visio Drawing Control. Set rttb.SelectedRtf = @"{\rtf1\ansi " + "Visible" + @"{\v " + "Hidden" + @"}}"; rttb.Text will then be "Visible" which is WRONG. i.e. the hidden text does not get set when the Visio Control is initialized before the RichTextBox. With the form displayed, this time pressing CTRL+F results in the Find Dialog being displayed with no problem. Any ideas? Thanks, B.