Rt...
左键点击时用的StatuText中的Url,
但右键“在新窗口中打开”时,StatuText为空,如何用其他的方法解决?
或怎样捕获右键“在新窗口中打开”时超连接的Url???
左键点击时用的StatuText中的Url,
但右键“在新窗口中打开”时,StatuText为空,如何用其他的方法解决?
或怎样捕获右键“在新窗口中打开”时超连接的Url???
解决方案 »
- vs的一个小问题
- 关于在C#中将数据导出到txt文件,格式问题
- imagelist索引越界
- 如何改变config的数据?
- C#线程创建时参数怎么传入,线程创建完成可以返回参数吗
- 家用电脑白天用作服务器(家中没人),晚上关机,安全吗?
- 程序员三生三世的郁闷之一(我倒,调试了三天了,不知错在那儿)
- c#.net调用水晶报表老是要有个数据库登录款出现,每次都要验证登录sqlserver才能看到报表,如何保存验证,不想每次都输入。
- 字符串向其它类型转换,string--->DateTime,String--->int32,string-->Decimal
- C怎么运行可执行文件。
- 重写方法和隐藏方法
- 请问一个关于数据类型判断的问题
我用的是2005的WebBrowser,不是老的axWebBrowser,网上资料说这两个控件好像有区别
代码里写Url=""===================================
问题就在于不知道右键“在新窗口中打开”时所点击连接的Url.....
左键点击连接时,StatuText值为所点击连接的地址,就可以直接Navigate了.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication2
{
public partial class Form1 : Form
{
public WebBrowser WebBrowser
{
get
{
return webBrowser1;
}
set
{
webBrowser1 = value;
}
} public Form1()
{
InitializeComponent();
} private void toolStripButton1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(toolStripTextBox1.Text);
} private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
Form1 f = new Form1();
f.WebBrowser.Navigate(webBrowser1.StatusText);
f.Show();
}
}
}------------------------------------namespace WindowsApplication2
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows 窗体设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(657, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripTextBox1,
this.toolStripButton1});
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(657, 25);
this.toolStrip1.TabIndex = 1;
this.toolStrip1.Text = "toolStrip1";
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 49);
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(657, 292);
this.webBrowser1.TabIndex = 2;
this.webBrowser1.NewWindow += new System.ComponentModel.CancelEventHandler(this.webBrowser1_NewWindow);
//
// toolStripTextBox1
//
this.toolStripTextBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
this.toolStripTextBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.AllUrl;
this.toolStripTextBox1.Name = "toolStripTextBox1";
this.toolStripTextBox1.Size = new System.Drawing.Size(100, 25);
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
this.toolStripButton1.Text = "toolStripButton1";
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(657, 341);
this.Controls.Add(this.webBrowser1);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "Form1";
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout(); } #endregion private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.WebBrowser webBrowser1;
private System.Windows.Forms.ToolStripTextBox toolStripTextBox1;
private System.Windows.Forms.ToolStripButton toolStripButton1;
}
}
只能用老的axWebBrowser吗??