zoukankan      html  css  js  c++  java
  • webBrowser 设置文本框

    private void Form1_Load(object sender, EventArgs e)
            {
                this.webBrowser1.Navigate("http://www.baidu.com");
                this.webBrowser1.ScriptErrorsSuppressed = true;
                //禁用右键菜单
                this.webBrowser1.IsWebBrowserContextMenuEnabled = false;
                //禁用键盘快捷键
                this.webBrowser1.WebBrowserShortcutsEnabled = false;
                //打开IE打印机会话框
                this.webBrowser1.ShowPrintDialog();
                //打开IE的打印预览会话框
                this.webBrowser1.ShowPrintPreviewDialog();
                //打开IE的保存 会话框
                this.webBrowser1.ShowSaveAsDialog();
               
            }

    #region 设置网页字段
            /// <summary>
            /// 设置网页字段
            /// </summary>
            /// <param name="strInput"></param>
            private void SetHtmlElementValue(string strInput)
            {
                try
                {
                    Clipboard.Clear();
                    Clipboard.SetDataObject(strInput);
                    IDataObject elementData = Clipboard.GetDataObject();
                    if (elementData.GetDataPresent(DataFormats.Text))
                    {
                        HtmlElement elem = this.webBrowser1.Document.ActiveElement;
                        elem.SetAttribute("value", strInput);
                    }
                    return;
                }
                catch (Exception ex)
                { }
            }

            #endregion

    private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
                SetHtmlElementValue("aaaaaaaaaaa");
            }

  • 相关阅读:
    自定义线性表
    网站关键词抓住热点话题获取长尾关键词 给网站增添流量(图)
    Hibernate常见注解说明
    面试问题java基础
    Spring常见的注解说明
    poj3268
    poj3273
    poj3250
    poj3277
    poj3253
  • 原文地址:https://www.cnblogs.com/jcgh/p/2013998.html
Copyright © 2011-2022 走看看