作者ganymade (呀)
看板C_Sharp
标题Re: [问题]有没有办法在windows form里放上网页呢?
时间Thu Mar 10 16:42:52 2005
※ 引述《ithinkurdumb (狂贺清大梅竹亚军四连霸)》之铭言:
: 我没用window form写过这样的程式,
: 不过以前有用VB, VC++写过.
: 大致上就是加入一个IE的component.
: 至於网页是什麽档案是不会有影响的,
: html, asp, aspx, php等等传到client端的时候都是一样的.
: 好像连flash也可以 (有装flash player的话).
你好
我想请问一下
我参考之前板上的一篇文章
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=312
里面一段
Note: The web browser is a generic content container and by default is
not initialized to an HTML container so you must first load some HTML
content before attempting to access the document or body properties.
The easiest way to do this is:
private void Form1_Load(object sender, System.EventArgs e)
{
// Goto a blank HTML page
Navigate("about:blank");
// Wait for the document to load
while (body == null) Application.DoEvents();
// Now you have full access to the body of a blank HTML page.
body.innerText = "Hello World";
}
之前还有一段是
private HTMLDocument document
{get {return (HTMLDocument) webMain.Document;}}
private HTMLBody body
{get {return (HTMLBody) document.body;}}
可是我不懂耶
因为我弄出来都会跑出错误讯息
类型 'System.NullReferenceException' 的未处理例外状况发生於 browser.exe
其他资讯: 并未将物件参考设定为物件的执行个体
错误的地方就是
body这个东西
我应该要怎麽做呢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.119.75.43