Home All Groups Group Topic Archive Search About

Using WebBrowser Control for simple display

Author
28 May 2006 2:30 PM
SkyHook
I'm experimenting with the WebBrowser control.  What I'd like to be able to
do is to change the display/contents of a WebBrowser control
programmatically whenever a ComboBox selection changes.  In other words,
this would basically be a Master/Detail presentation with the ComboBox
containing the Master and the WebBrowser containing the detail.

I have everything in place: the controls all work and the display works - to
a point.

The problem is with _changing_ the contents of the WebBrowser control.  The
FIRST time I 'populate' the WebBrowser control, everything is fine.
However, when I try to change the WebBrowser control display, (via
ComboBox.SelectedIndexChanged()) nothing happens - that is, the display does
not change.  Here's the pertinent code

public void MyWebBrowser_Populate(XmlNode xNode)
{
     StringBuilder sb = new StringBuilder();

     XmlNodeList nodeList = xNode.SelectNodes("PHONE");

     sb.Append("<html><body>");
     sb.Append("List.Count[" + nodeList.Count + "]");
     sb.Append("<html><body>");

     MyWebBrowser.DocumentText = sb.ToString();
}

I have checked 'nodeList' with the debugger and verified that it contains a
different node count on different occasions.

I am thinking that I need to do some sort of 'Clear' or 'Init' on the
WebBrowser control before changing it, but I have not been able to find
anything in the API that will allow me to do that. (MyWebBowser.DocumentText
= ""; does not do it.)

Any help is greatly appreciated.

TIA

Author
29 May 2006 12:54 PM
SkyHook
Well I never could make this work.  I ended up writing the HTML out to a
file and using the .Url() and .Refresh() from the WebBrowser control API.
If anyone finds a way to do this all in-memory, please post the solution for
us.

Show quote
"SkyHook" <SkyH***@-fubacor.com> wrote in message
news:juieg.10836$cB3.2923@tornado.tampabay.rr.com...
> I'm experimenting with the WebBrowser control.  What I'd like to be able
> to do is to change the display/contents of a WebBrowser control
> programmatically whenever a ComboBox selection changes.  In other words,
> this would basically be a Master/Detail presentation with the ComboBox
> containing the Master and the WebBrowser containing the detail.
>
> I have everything in place: the controls all work and the display works -
> to a point.
>
> The problem is with _changing_ the contents of the WebBrowser control.
> The FIRST time I 'populate' the WebBrowser control, everything is fine.
> However, when I try to change the WebBrowser control display, (via
> ComboBox.SelectedIndexChanged()) nothing happens - that is, the display
> does not change.  Here's the pertinent code
>
> public void MyWebBrowser_Populate(XmlNode xNode)
> {
>     StringBuilder sb = new StringBuilder();
>
>     XmlNodeList nodeList = xNode.SelectNodes("PHONE");
>
>     sb.Append("<html><body>");
>     sb.Append("List.Count[" + nodeList.Count + "]");
>     sb.Append("<html><body>");
>
>     MyWebBrowser.DocumentText = sb.ToString();
> }
>
> I have checked 'nodeList' with the debugger and verified that it contains
> a different node count on different occasions.
>
> I am thinking that I need to do some sort of 'Clear' or 'Init' on the
> WebBrowser control before changing it, but I have not been able to find
> anything in the API that will allow me to do that.
> (MyWebBowser.DocumentText = ""; does not do it.)
>
> Any help is greatly appreciated.
>
> TIA
>
>

AddThis Social Bookmark Button