C# 使用微软网页浏览器控件 译文见:http://blog.csdn.net/Felomeng/archive/2007/05/17/1613495.aspx Summary: This walkthrough demonstrates how to use the Microsoft Web browser control and the Microsoft Document Object Model (DOM) to programmat
C#使用微软网页浏览器控件
译文见:http://blog.csdn.net/Felomeng/archive/2007/05/17/1613495.aspx
Summary: This walkthrough demonstrates how to use the Microsoft Web browser control and the Microsoft Document Object Model (DOM) to programmatically access the elements of any Web page. (3 pages)
To access the DOM programmatically, you import both the Web browser component and references to the methods, properties, and events of the DOM into your C# project. You direct the Web browser to a URL by calling its Navigate method, and you must then wait for the documentation complete event. You obtain the document by casting the Web browser Document property to an IHTMLDocument2 interface object. You can query this object for its collections, such as its link or image collections, which are returned as IHTMLElementCollection objects.
In this walkthrough, you will use the Web browser and DOM to obtain and display all anchors found in a Web page.
To access the DOM programmatically
- Create a new Visual C# Windows Application project named DOM.
The form name defaults to Form1.
- In Solution Explorer, right-click the References folder and select Add Reference.
The Add Reference dialog box opens.
- Click on the .NET tab and double-click the component named Microsoft.mshtml.
- Click OK.
References to the methods, events, and properties of the Microsoft DOM are added to the project.
- Open the Toolbox, right-click any tool, and choose Customize Toolbox.
The Customize Toolbox dialog box opens.
- Click on the COM Components tab and check Microsoft Web Browser.
The Web browser control labeled Explorer is added to the Toolbox components.
- Select the Explorer component and click the open form.
A Web browser component named axWebBrowser1 is added to the form.
- Add a TextBox component above the browser component and a ListBox component below it, accepting the default names of textBox1 and listBox1.
- Add a Button component to the right of listBox1. Change the Text property to "Submit," and accept the default name of button1.
The resulting form should look similar to the following screen shot:
- Double-click on button1.
The button1_Click method is added to the project.
- Replace the body of the button1_Click method with the following bold code:
private void button1_Click(object sender, System.EventArgs e) { <code><strong> object Zero = 0;</strong></code> <code><strong> object EmptyString = "";</strong></code> <code><strong> <span>axWebBrowser1</span>.Navigate(textBox1.Text,</strong></code> <code><strong> ref Zero, ref EmptyString, ref EmptyString, ref EmptyString);</strong></code> }
- Return to the form designer, select the browser component, and click the Events icon in the Properties window.
A list of Web browser events appears.
- Double-click the Document Complete event.
The axWebBrowser1_DocumentComplete event handler is added to the project.
- Add the following bold line of code to the beginning of the file Form1.cs:
using System.Data; <strong>using mshtml;</strong>
- Replace the body of the axWebBrowser1_DocumentComplete event handler with the following code:
private void <span>axWebBrowser1</span>_DocumentComplete( object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { <code><strong> IHTMLDocument2 HTMLDocument = </strong></code> <code><strong> (IHTMLDocument2) <span>axWebBrowser1</span>.Document;</strong></code> <code><strong> IHTMLElementCollection links = HTMLDocument.links;</strong></code> <code><strong> listBox1.Items.Clear();</strong></code> <code><strong> foreach (HTMLAnchorElementClass el in links)</strong></code> <code><strong> {</strong></code> <code><strong> listBox1.Items.Add(el.outerHTML);</strong></code> <code><strong> }</strong></code> }
- Press F5 to build and run the project.
The Form1 application appears.
- Type a URL—such as www.msn.com—into the text box and click Submit.
The Web page is displayed in the browser, and a list of its anchors appears in the list box, as shown in the following screen shot.
For more information, see the following topics in the MSDN Library:
- Dynamic HTML (http://msdn.microsoft.com/library/en-us/iisref/html/psdk/asp/eadg39v0.asp)
- IHTMLDocument2 interface (http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/document2/document2.asp)

Access 验证规则是一种数据验证工具,用于确保数据符合特定条件,防止输入无效数据。设置验证规则的步骤:1. 选择要设置验证规则的字段;2. 打开“字段属性”对话框并切换到“查找”选项卡;3. 在“验证规则”字段中输入验证规则;4. 在“验证文本”字段中输入不符合规则时的错误消息;5. 单击“确定”保存更改。

microsoft access是由微软发布的关系数据库管理系统;它结合了MicrosoftJet Database Engine和图形用户界面两项特点,是Microsoft Office的系统程序之一。

access和trunk端口的区别:1、Access端口用于连接终端设备,提供单个VLAN的接入,而Trunk端口用于连接交换机之间,提供多个VLAN的传输;2、Access端口只传输属于指定VLAN的数据,而Trunk端口可以传输多个VLAN的数据,并使用VLAN标签进行区分。

vb中连接access数据库的步骤包括引用必要的命名空间、创建连接字符串、创建连接对象、打开连接、执行SQL语句和关闭连接。详细介绍:1、引用必要的命名空间,在VB项目中,首先需要引用“System.Data`和`Microsoft.Office.Interop.Access”命名空间,以便使用ADO.NET和Access相关的类和方法,可以在VB项目的引用中添加这些命名等等。

Access 数据库文件的扩展名为 .accdb,自 Microsoft Access 2007 起开始使用,用于识别包含结构化数据的容器文件,如表、查询和窗体。

Microsoft Access 是一款关系型数据库管理系统 (RDBMS),用于存储、管理和分析数据。它主要用于数据管理、导入/导出、查询/报表生成、用户界面设计和应用程序开发。Access 优势包括易用性、集成数据库管理、强大灵活、与 Office 集成和可扩展性。

在 Access SQL 中,使用 FORMAT 函数,并将格式指定为 "00",可以将数字 1 显示为文本格式 "01"。

微软 Access 数据库是一种关系型数据库管理系统,主要用途包括:数据存储和管理:储存各种类型的数据并将其组织为表格。数据查询和检索:提供强大的查询工具以查找特定数据。报告和表单设计:创建专业报告和表单以显示和打印数据。应用程序开发:使用 VBA 开发简单应用程序以自动化流程。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

Dreamweaver Mac版
视觉化网页开发工具

Atom编辑器mac版下载
最流行的的开源编辑器

禅工作室 13.0.1
功能强大的PHP集成开发环境