很急的问题!!!

nocolor 2005-02-06 11:19:30
C#做的windows应用程序,怎样在form里集成一个web浏览器的控件,实现在form里显示一个网页。

我从Com里找了一个说是web浏览器,但加进来之后,说localurl为只读,不能设置,要是这样的话那怎么打开那个地址啊。

还有没有别的方法。这个功能实现后就像瑞星一样,窗体里面显示新闻。
...全文
223 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
nga96 2005-02-12
  • 打赏
  • 举报
回复
UP,
程序的色彩 2005-02-09
  • 打赏
  • 举报
回复
呵呵,该讲的上面的朋友都讲了.祝大家新年快乐.万事如意!
cppTrier 2005-02-09
  • 打赏
  • 举报
回复
2005中的托管控件也只不过是对WebBrowser这个ActiveX Control的包装。如果程序想运行在.net 1.0或1.1上,直接用这个控件也不错。
Abel.Liu 2005-02-08
  • 打赏
  • 举报
回复
建议用2005中的托管控件,趋势阿。
terryshi 2005-02-08
  • 打赏
  • 举报
回复
up,不懂~
cppTrier 2005-02-08
  • 打赏
  • 举报
回复
用activeX里的WebBrowser控件就可以,VS2005里的WebBrowser控件是对这个ActiveX控件的包装。这个控件使用起来相当简单,首先在工具箱里(ToolBox)里点鼠标右键选 add/remove items,在出来的窗口中选择COM Components,在其中勾选Microsoft Web Browser。

然后向窗体加入一个该控件。在合适的地方(Form_Load或者某个按钮事件)中,添加:


string pageUrl = "http://...";//你要显示的页面的URL
object o = System.Reflection.Missing.Value;
axWebBrowser1.Navigate(pageUrl,ref o,ref o,ref o,ref o);
hawk234 2005-02-08
  • 打赏
  • 举报
回复
up
broadury 2005-02-07
  • 打赏
  • 举报
回复
统一楼上。Navigate方法就可以了
egxsun 2005-02-07
  • 打赏
  • 举报
回复
现在用vs.net2003的多一些吧,用2005的话框架又要重新装
marvelstack 2005-02-07
  • 打赏
  • 举报
回复
还是使用vs.net 2005里那个托管的web浏览器控件吧。
xiongchen 2005-02-06
  • 打赏
  • 举报
回复
可以加发一封Email给我,我有一个详尽的例子给你看!
xiongchen2046@163.com
AllenTing 2005-02-06
  • 打赏
  • 举报
回复

点“工具”菜单,然后点击“自定义工具葙”弹出对话框,找到IE控件,单击引用,然后回到主页面,工具葙中已经加入了IE浏览器
一个例子:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace oa
{
/// <summary>
/// viewNotice 的摘要说明。
/// </summary>
public class viewNotice : System.Windows.Forms.Form
{
private AxSHDocVw.AxWebBrowser axWebBrowser1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public viewNotice()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
int zero=0;
object ozero=zero;
string empty="";
object oempty=empty;
this.axWebBrowser1 .Navigate ("http://192.168.0.29:8080/notice.jsp?name="+oa.Form1 .stringCurentUser ,
ref ozero,
ref oempty,
ref oempty,
ref oempty);
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(viewNotice));
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();
this.SuspendLayout();
//
// axWebBrowser1
//
this.axWebBrowser1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.axWebBrowser1.Enabled = true;
this.axWebBrowser1.Location = new System.Drawing.Point(16, 16);
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));
this.axWebBrowser1.Size = new System.Drawing.Size(496, 280);
this.axWebBrowser1.TabIndex = 0;
//
// viewNotice
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(528, 317);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.axWebBrowser1});
this.MaximizeBox = false;
this.Name = "viewNotice";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "查看通知";
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();
this.ResumeLayout(false);

}
#endregion
}
}

RockyZhang 2005-02-06
  • 打赏
  • 举报
回复
在工具箱里添加/移除项.
在COM组件中选择Miscrosoft Web....  路径是C:\Winnt\System32\shdocvw.dll.
添加完成后工具箱中会多一个Miscrosfot Web....的东东.
这个就是用来在WinForm中显示Web页的.
在你的代码中写下面的代码就可以了.

object missing=Missing.Value;
this.axWebBrowser1.Navigate("http://www.sina.com",ref missing,ref missing,ref missing,ref missing);
Samen168 2005-02-06
  • 打赏
  • 举报
回复
Object o = new object();
this.axWebBrowser1.Navigate(yourURL,ref o,ref o,ref o,ref o);
doubon 2005-02-06
  • 打赏
  • 举报
回复
在VS2005中已经内置了Web浏览器控件!

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧