Vb.net WebBrowser不会刷新 [英] Vb.net WebBrowser will not Refresh

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

问题描述

我正在使用WebBrowser,并希望每次加载同一页面时刷新它,它将每隔10秒执行一次。所以我需要快速代码,我已经看到msdn上的代码很长。



下面是我现在的代码,但我已经尝试了所有我能做的事情想到并且仍然无法让它刷新



I am using WebBrowser and want it to refresh every time it loads the same page, it will be doing this about every 10 sec. so I need fast code, I have seen the code on msdn it is to long.

Below is the code I have now, but I have tried every thing I can think of and still can not get it to refresh

Sub ShowIEScr(mywebpage as string)
  dim wb as new WebBrowser 
  wb = WebBrowser1 ''Tried this to see if I could kill and reload did not work
  
  wb.Refresh(WebBrowserRefreshOption.Completly) ''all option do not work

  wb.Navigate(mywebpage) ''this is the hart of what I want to do the rest of the code is just tring to get it to refresh
  wb.visible = true ''set to false elswhere, did not work
  wb.WebBrowserShortcutsEnabled = true
  SendKeys.send("{F5}")  ''still did not work
  ''I set the hight and width then 
end sub





我试图使用相同代码的AxWebBrowser试试运气



我尝试的每件事我都无法使用浏览器刷新

我在IE中加载了相同的网页,当F5被点击时它会刷新

上面的子点是从一个timmer调用的

另外mywebpage更改每次调用不同的页面然后旋转回原来

不确定它是否重要但是这个应用程序需要运行,因为Windows服务没有尝试作为exe运行但不认为这很重要。



I have tried to use the AxWebBrowser with same code tries no luck

Every thing I try I can not get the Browser to refresh
I loaded same webpage in IE and it will refresh when F5 is hit
The above sub is called from a timmer
Also mywebpage changes every call to a different page then rotates back to original
Not sure if it matters but this app needs to run as a Windows service have not tried to run as a exe but do not think it matters.

推荐答案

你所做的根本没有意义。每次调用函数时,都会创建一个新的浏览器。您不能将浏览器的此实例添加到任何控件。基本上,你什么都不做。你只是创建新的实例而且从不显示你做的事情。



相反,你需要只有一个浏览器的实例。使其成为表单类的成员。您应该将此实例作为子控件添加到窗体或面板中。看起来你已经做到了,但是不要使用浏览器的这个实例 - 难怪它不会刷新。



(我觉得你需要学习很多类,实例,OOP,事件等基础知识。这个组件使用起来非常棘手。通过你对事物的理解,我可以预见到越来越多的麻烦。试着去学习一些非常简单的例子。)



并帮自己一个忙 - 忘记 SendKeys



-SA
What you do makes no sense at all. You create a new Browser every time your function is called. You don''t add this instance of the Browser to any control. Essentially, you don''t do anything. You just create new instances and never show what you do.

Instead, you need to have only one instance of the Browser. Make it a member of your form class. You should added this instance as a child control to a form or a panel. It looks like you already did it, but don''t use this instance of the Browser — no wonder it does not refresh.

(I feel you need to learn very basics of classes, instances, OOP, events, etc. This component is pretty tricky to use. With your understanding of things I can foresee more and more trouble. Try to learn all that on some really simple examples.)

And do yourself a favor — forget SendKeys.

—SA


Webbrowser需要先导航。



然后刷新工作。



Webbrowser.Navigate(url)





加载时,



然后通过计时器或按钮刷新它。



Webbrowser.Refresh()



OR,

Webbrowser.Refresh(完全​​)
Webbrowser needs to be navigated first.

Then Refresh works.

Webbrowser.Navigate("url")


when loads,

then refresh it through timer or button.

Webbrowser.Refresh()

OR,
Webbrowser.Refresh(Completely)


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

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