1 question. -
Ok. I really dont know how to ask a question. Basically, I have two rich textboxs. In one I have html code, and i want to the other read the code that is in the first rich textbox and display it as if it were in a web browser.
2 question -
Now, I have a rich textbox, and a web browser. I want the web browser to be able to read the code in the rich textbox. Can someone help

RichTextBox
Decima
RichTextBox richTextBox1;
WebBrowser webBrowser1;
These would have been created automatically by the designer and hidden away. To access the text of the RTB use richTextBox1.Text to get the entire text in the control.
As far as automating this you will probably have to manage this on the form itself. You need to decide when the contents of the RTB get flushed to the WB. It can be either whenever the text changes or when the user clicks a button. In either case handle the event on the form, get the text from the RTB and set the WB's DocumentText property. You'll need to make sure the string you pass it is a well-formed HTML document first so you might need to do some preprocessing. Here is some sample code (assumes the text in the RTB is properly formed):
private void OnTextChanged ( object sender, EventArgs e )
{
//Get the text
string text = richTextBox1.Text;
//Do any processing on the text such as making it well-formed
...
//Send to the web browser
webBrowser.DocumentText = text;
}
The above code assumes that the WB is already set to handle the document text. You may need to preload a dummy HTML page or do other setup work first. I'm not sure.
Hope this helps,
Michael Taylor - 10/8/05
nitamedi
P.S. I also didnt get what you meant by making the text "well-formed".
Stiner
Xamedes
The thing that confuses me is that you're using a tab control. Tab controls are designed to group related controls and hide them from the user if they're not needed for the task at hand. It sounds like you want to have both the reich text box and the web browser visable simultaneously. If so, just put both those controls side-by-side on the form.
Now, as the userr types, you can examine the text and update the browser control by handling the TextChanged event as the previous poster indicated.
By "well formed", the previous poster means that the HTML syntax needs to be checked. Any opened tags should be closed, tags can't overlap, etc. See any HTML guide for details.
As a final tip, I hope you're just doing this as a learning exercise. There are many commercial, open source and free products that do this. Reinventing the wheel may not be the best use of your time.