本人做一个winfrom程序,要在一窗口中加入axwebbrorwser控件,显示自己的一个网页
但无法显示,请高手们请教!本人代码:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Web;
namespace Online_Library_One
{
/// <summary>
/// Borrow 的摘要说明。
/// </summary>
public class Borrow : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private AxSHDocVw.AxWebBrowser axWebBrowser1;
public static Borrow bf = null; public static void show_load()
{
if (bf == null)
{
bf = new Borrow();
bf.Show();
}
else
bf.Show();
} public Borrow()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Borrow));
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();
this.SuspendLayout();
// 
// axWebBrowser1
// 
this.axWebBrowser1.Enabled = true;
this.axWebBrowser1.Location = new System.Drawing.Point(8, 8);
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));
this.axWebBrowser1.Size = new System.Drawing.Size(448, 296);
this.axWebBrowser1.TabIndex = 0;
// 
// Borrow
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(624, 317);
this.Controls.Add(this.axWebBrowser1);
this.Name = "Borrow";
this.Text = "Borrow";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Borrow_Closing);
this.Load += new System.EventHandler(this.Borrow_Load);
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();
this.ResumeLayout(false); }
#endregion private void Borrow_Load(object sender, System.EventArgs e)
{
ShowBorrow();
}
public void ShowBorrow()
{
object a = null;
axWebBrowser1.Navigate("http://www.21cn.com",ref a,ref a,ref a,ref a);
} private void Borrow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
bf = null;
}
}
}用了Navigate可无法显示......请大锅们看看..在线等另:有没有关与WebBrowser的详细介绍,最好能有实例.....

解决方案 »

  1.   

    楼主代码应该没问题
    你把下面代码删了试试,也不知道你是在何时调用那代码的:
    public static Borrow bf = null;public static void show_load()
    {
    if (bf == null)
    {
    bf = new Borrow();
    bf.Show();
    }
    else
    bf.Show();
    }
    已经在另一贴中给你回了,我写了个浏览器,参考:http://weste.net/2005/6-26/09423763743.html有空你也去写一个
    你的问题是很简单的,你先删除了那须代码试试吧
      

  2.   

    代码应该没问题,请检查一下
    1、引用里是否又 ASHDocVw 和 SHDocVw 两个东西在,如果没有,axWebBrowser是无法显示的
    2、检查 debug 目录里有没有 AxInterop.SHDocVw.dll 和 Interop.SHDocVw.dll 两个文件,如果没有程序可能会运行异常
      

  3.   

    WINFORM中放入控件axWebBrowser1后,VS。NET2003会自动添加AxSHDocVw 和 SHDocVw 的引用的,如果自己写浏览器可能还要添加对Microsoft.mshtml的引用