【问题标题】:Display message on button_click在 button_click 上显示消息
【发布时间】:2015-01-02 19:27:23
【问题描述】:

我的表单中有一个名为 WebBrowser1 的 webBrowser 控件。 我使用以下代码将值拉到复选框和其他控件中:

 WebBrowser1.Document.GetElementById("LastName").SetAttribute("value", "MyLastname")'<--- pull value to the textbox
 WebBrowser1.Document.GetElementById("TermsOfService").SetAttribute("value", "yes")'<--- change the value of a check box

当用户单击浏览器中的按钮时,我需要显示一个消息框。 我如何跟踪点击?,即使是 C# 代码也是可以接受的,所以我标记为 C#

【问题讨论】:

    标签: c# vb.net button browser webbrowser-control


    【解决方案1】:

    您可以向要监控的按钮添加一个处理程序,例如,我在 webbrowser 控件的 DocumentCompleted 事件触发后添加了一个处理程序

    Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    
        Dim htmlBtn As HtmlElement = WebBrowser1.Document.GetElementById("BtnID")
    
        If htmlBtn IsNot Nothing Then 
            AddHandler htmlBtn.click, AddressOf YourSub
        End If
    
    End Sub
    
    Private Sub YourSub()
        messagebox.show("clicked!")
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-29
      • 2012-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多