C # in AxWebBrowser to submit a form, or click on an object

xiaoxiao2021-03-06  52

DDDD.htm

--------------------------- -------------------------------------------------- ----- Form1.csusing system; use system.drawing; use system.collections; using system.componentmodel; using system.windows.form; using system.data; using mshtml;

Summary description of Namespace WindowsApplication2 {///

/// Form1. /// public class Form1: System.Windows.Forms.Form {private AxSHDocVw.AxWebBrowser axWebBrowser1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; /// // Required designer variable. /// private system.componentmodel.container components = null;

Public Form1 () {// // Windows Form Designer Support for // InitializeComponent ();

// // Todo: Add any constructor code after INITIALIZEComponent call //}

///

/// Clean all the resources being used. /// Protected Override Void Dispose (Bool Disposing) {if (disponents! = Null) {components.dispose ();}} Base.Dispose

#REGION Windows Form Designer The code ///

/// designer supports the required method - do not use the code editor to modify the // / this method.

/// private void InitializeComponent () {System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof (Form1)); this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser (); this.button1 = new System .Windows.forms.button (); this.button2 = new system.windows.Forms.Button () (); (this.axwebbrowser1)). BeginInit (); this.suspendlayout (); / / // axWebBrowser1 // this.axWebBrowser1.Enabled = true; this.axWebBrowser1.Location = new System.Drawing.Point (80, 184); this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State) ("AxWebBrowser1.OCxState))))))))))); this.axwebbrowser1.size = new system.drawing.size (300, 150); this.axwebbrowser1.tabindex = 0; /// Button1 // this.button1 .Location = new system.drawing.point (160, 96); this.button1.name = "button1"; this.button1.size = new system.drawing.size (88, 24); this.button1.tabindex = 1 This.button1.text = "Button1" This.Button1.click = new system.EventHandler (this.button1_click); // // button2 // this.button2.location = new system.drawing.point (304, 96); this.button2.name = " Button2 "; this.button2.tabindex = 2; this.button2.text =" button2 "; this.button2.click = new system.eventhandler (this.button2_click); // // form1 // this.autoscaleBaseSize = new System.drawing.size (6, 14); this.clientsize = new system.drawing.size (584, 397); this.controls.add (this.button2); this.Controls.add (this.button1); this .Controls.add (this.axwebbrowser1); this.name = "form1";

This.Text = "Form1"; (this.axwebbrowser1)). endinit (); this.ResumeLayout (false);} #ENDREGION

///

/// The primary entry point of the application. /// [stathread] static void main () {Application.run (new form1 ());}

private void button1_Click (object sender, System.EventArgs e) {object x = System.Reflection.Missing.Value; axWebBrowser1.Navigate (@ "E: / Documents and Settings / Administrator / Desktop /dddd.htm", ref x, ref X, REF X, REF X);

private void button2_Click (object sender, System.EventArgs e) {mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2) axWebBrowser1.Document; mshtml.IHTMLFormElement f1 = (mshtml.IHTMLFormElement) doc.all.item ( "form1", 0); ((MSHTML.IHTMLFORMELEMENT) (f1)). Submit (); mshtml.ihtmlelement element = (mshtml.ihtmlelement) Doc.all.Item ("Button1", 0); element.click ();}}}

转载请注明原文地址:https://www.9cbs.com/read-80914.html

New Post(0)