WebBrowser控件自动刷新 [英] WebBrowser control auto refresh

查看:354
本文介绍了WebBrowser控件自动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Visual Basic中的Visual Studio 2008中制作一个程序。它涉及一个Web浏览器,我想使其自动刷新,并允许人们选择他们想要自动刷新的时间段。不需要用户输入,但是我有预先设置的复选框。我认为使用计时器和 WebBrowser1.Refresh()方法可能是可行的。如果我弄错了,请纠正我,并告诉我该怎么做。

I want to make a program in Visual Studio 2008 in Visual Basic. It involves a web browser and I want to make it auto refresh and allow people to choose the time period in which they want to auto refresh. It won't take user input but I have checkboxes that are preset. I think this may be possible using a timer and the WebBrowser1.Refresh() method. If I am mistaken, please correct me and tell me how to do this.

推荐答案

从我收集到的信息来看,看来你正在尝试在VB.NET中创建WinForms应用程序。要实现您的目标,您可以:

From what I gather, it seems that you are trying to create a WinForms application in VB.NET. To accomplish your goal, you can:


  1. 创建NumericUpDown或Textbox控件以允许用户选择刷新时间段(您可以决定是秒,分钟还是其他时间)。

  2. 创建Timer对象,并使用TextChanged事件文本框或NumericUpDown控件的 ValueChanged事件中,将输入的值设置为等于计时器的间隔。

  3. 创建按钮来调用计时器的启动和停止功能,以允许用户启动和停止自动刷新。

  4. 订阅计时器的滴答事件引发/触发事件时,请调用WebBrowser的Refresh方法

  1. Create a NumericUpDown or Textbox control to allow users to select a refresh time period (you can decide whether you want this to be in seconds, minutes, or something else).
  2. Create a Timer object, and using the TextChanged event of the textbox or the ValueChanged event of the NumericUpDown control, set the entered value equal to the interval of the Timer.
  3. Create buttons that call the Timer's start and stop function, to allow the user to start and stop auto-refreshing.
  4. Subscribe to the Timer's Tick event and call the WebBrowser's Refresh method when the event is raised/fired.

下面是一些示例代码。

Public Class Form1
    Private Sub numInterval_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles numInterval.ValueChanged
        Timer1.Interval = numInterval.Value
    End Sub

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        Timer1.Start()

    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
        Timer1.Stop()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        WebBrowser1.Refresh(WebBrowserRefreshOption.Completely)
    End Sub
End Class

如您所见,我在Timer1中添加了事件处理程序勾号和numInterval.ValueChanged。

As you can see, I have added event handlers to Timer1.Tick and numInterval.ValueChanged.

这篇关于WebBrowser控件自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆