webbrowser-control

Parsing StringBuilder HTML to WebBrowser control using C#

南笙酒味 提交于 2019-12-25 02:13:17
问题 I have the following code: private StringBuilder htmlMessageBody(DataGridView dataGridView2) { StringBuilder strB = new StringBuilder(); //create html & table strB.AppendLine("<html><body><center><" + "table border='1' cellpadding='0' cellspacing='0'>"); strB.AppendLine("<tr>"); //cteate table header for (int i = 0; i < dataGridView2.Columns.Count; i++) { strB.AppendLine("<td align='center' valign='middle'>" + dataGridView2.Columns[i].HeaderText + "</td>"); } //create table body strB

Parsing StringBuilder HTML to WebBrowser control using C#

删除回忆录丶 提交于 2019-12-25 02:11:53
问题 I have the following code: private StringBuilder htmlMessageBody(DataGridView dataGridView2) { StringBuilder strB = new StringBuilder(); //create html & table strB.AppendLine("<html><body><center><" + "table border='1' cellpadding='0' cellspacing='0'>"); strB.AppendLine("<tr>"); //cteate table header for (int i = 0; i < dataGridView2.Columns.Count; i++) { strB.AppendLine("<td align='center' valign='middle'>" + dataGridView2.Columns[i].HeaderText + "</td>"); } //create table body strB

Parse a HTML combox in C#

纵饮孤独 提交于 2019-12-25 01:46:11
问题 I need parse a select value in html file. I have this html file: <html> <head></head> <body> <select id="region" name="region"> <option value="0" selected>Všetky regiony</option> <optgroup>Banskobystrický kraj</optgroup> <option value="k_1">Banskobystrický kraj</option> <option value="1">Banská Bystrica</option> <option value="3">Banská Štiavnica</option> <option value="18">Brezno</option> <option value="22">Detva</option> <option value="58">Dudince</option> </select> </body> </html> I need

Must pass uppercase to set MSHTML element attribute (.setAttribute) correctly, why? And CaseInsensitive .setAttribute doesn't work

前提是你 提交于 2019-12-25 00:48:44
问题 Basically, I am using .setAttribute to try and add/change the target attributes value in an anchor tag (). The whole problem started because when using .setAttribute "target", "_self" the HTML is written without any double quotes surrounding the "_self", ie: <a href="..." target=_self>link</a>. The only way to get "_self" saved with double quotes around it is to ensure that there is at least one uppercase letter (or more or all uppercase) in the attribute name TARGET, so doing a .setAttribute

System.Windows.Forms.WebBrowser.Refresh showing previous page

送分小仙女□ 提交于 2019-12-25 00:24:30
问题 My WinForms application has a tab with a System.Windows.Forms.WebBrowser control. There are several controls that set the WebBrowser's .Url property, and when the form repaints it calls the WebBrowser's .Refresh(WebBrowserRefreshOption.Completely) method. Occasionally, however, the form gets repainted and the WebBrowser content doesn't change. I break on the .Refresh( ) , and the .Url is the previous Url. What's going on? According to MSDN: If you set the value of this property and then

How to use Web Browser Control in for loop?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 21:47:27
问题 I am working on web crawler in which it checks the results of students from same website. I am able to submit the form and select elements but the problem is that i want to use web browser control in a loop. for (int i = 3910001; i < 391537; i++) { webBrowser1.Navigate(url); } Basically i want to navigate to url and submit the form and pick some elements from the returned HTml . So i used webBrowser1_DocumentCompleted . private void webBrowser1_DocumentCompleted(object sender,

Change target of links in WebBrowser control

你。 提交于 2019-12-24 18:06:10
问题 Sometimes when I click on a link, it opens in a new window. Can I prevent this from happening and just load the page in my current window? 回答1: This is working for me (so far): Private Sub browser_NewWindow(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles browser.NewWindow e.Cancel = True browser.Navigate(browser.StatusText) End Sub Really simple, if the status text is the url (which it always is for the documents I am browsing) 回答2: If you are targeting Windows XP SP2 or

WebBrowser Inject Javascript To Set the Focus to the First Input Box

淺唱寂寞╮ 提交于 2019-12-24 16:19:15
问题 I would like to inject a javascript in order to set the focus to the first input box. My current code is this: Me.WebBrowser1.Focus() Dim i& Dim JS(100) As String 'The following Javascript-injection ensures, that the first 'found input-element (if there is one) will be focused ' i = i + 1 : JS(i) = "<script>" i = i + 1 : JS(i) = "var inputElements = document.getElementsByTagName('input');" i = i + 1 : JS(i) = "for(i=0; i<inputElements.length; i++)" i = i + 1 : JS(i) = "{" i = i + 1 : JS(i) =

Printing in landscape from a Windows Forms WebBrowser control

社会主义新天地 提交于 2019-12-24 16:17:57
问题 I have a WebBrowser control in a Windows Forms Host in a WPF application. I know that in order to print it's contents, I use simply WebBrowser.Print() , however, how can I tell the printer to print the contents in landscape rather than a portrait orientation? I've been searching the Internet on this and oddly enough, it seems to be actually something that is a bit hard to do -- is this really the case? It seems odd to me that it wouldn't be easily implementable. Thanks! 回答1: INFO:

Prevent webbrowser from formating html file in c#

孤街浪徒 提交于 2019-12-24 15:56:43
问题 I have some trouble using the webbrowser control in C#, especially when I print it. The thing is, I have a Barcode in my html file and I have to print it (I use a font to create the code). When I open the html file with Firefox or any other Web browser, my barecode is good and I can scan it. But, when I open my file with my webbrowser in c#, or when I print it, the webbrowser ad 2 characters after the barecode. And, when I print the file, my document is not centered, it's like the webbrowser