-
Aug 3rd, 2020, 07:11 AM
#1
Thread Starter
New Member
how to get webbrowser GetElementById to datagridview1
I am using this code but ..all data goto datagridview column1.
I am need a column2 and column 3
thanks
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://student.emis.gov.eg/new/")
WebBrowser1.Visible = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Clear()
DataGridView1.ClearSelection()
TextBox1.Text = WebBrowser1.Document.GetElementById("ctl00_Lblsch").InnerText
WebBrowser1.Document.GetElementById("ctl00_ContentPlaceHolder1_Dropdownlist1").SetAttribute("value", combbox.Text) ' الصف
Try
Dim elem As HtmlElement = WebBrowser1.Document.GetElementById("ctl00_ContentPlaceHolder1_GridView1")
Dim count As Integer = 0
For Each rowElem As HtmlElement In elem.GetElementsByTagName("td")
Try
DataGridView1.Rows.Add(rowElem.InnerText)
Catch ex As Exception
End Try
Next
Catch exc As ArgumentOutOfRangeException
End Try
End Sub
-
Aug 3rd, 2020, 07:21 AM
#2
Re: how to get webbrowser GetElementById to datagridview1
Please don't post unformatted code snippets. They are too hard to read.
vb.net Code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://student.emis.gov.eg/new/")
WebBrowser1.Visible = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Clear()
DataGridView1.ClearSelection()
TextBox1.Text = WebBrowser1.Document.GetElementById("ctl00_Lblsch").InnerText
WebBrowser1.Document.GetElementById("ctl00_ContentPlaceHolder1_Dropdownlist1").SetAttribute("value", combbox.Text) ' الصف
Try
Dim elem As HtmlElement = WebBrowser1.Document.GetElementById("ctl00_ContentPlaceHolder1_GridView1")
Dim count As Integer = 0
For Each rowElem As HtmlElement In elem.GetElementsByTagName("td")
Try
DataGridView1.Rows.Add(rowElem.InnerText)
Catch ex As Exception
End Try
Next
Catch exc As ArgumentOutOfRangeException
End Try
End Sub
-
Aug 3rd, 2020, 07:23 AM
#3
Re: how to get webbrowser GetElementById to datagridview1
If you call Rows.Add and pass one value every time then obviously you will get rows with only one value in them. If you want rows with three values in them then you have to pass three values when you call Rows.Add. Get the three values first, then add the row.
-
Aug 3rd, 2020, 07:46 AM
#4
Thread Starter
New Member
Re: how to get webbrowser GetElementById to datagridview1
Originally Posted by jmcilhinney
If you call Rows.Add and pass one value every time then obviously you will get rows with only one value in them. If you want rows with three values in them then you have to pass three values when you call Rows.Add. Get the three values first, then add the row.
thanks
-
Aug 3rd, 2020, 07:57 AM
#5
Thread Starter
New Member
Re: how to get webbrowser GetElementById to datagridview1
this is my project show
-
Aug 3rd, 2020, 09:45 AM
#6
Re: how to get webbrowser GetElementById to datagridview1
We know what a DataGridView looks like. That doesn't change the fact that, if you want to populate multiple columns, you need to pass multiple values when calling Rows.Add.
-
Aug 3rd, 2020, 10:32 AM
#7
Thread Starter
New Member
Re: how to get webbrowser GetElementById to datagridview1
Originally Posted by jmcilhinney
We know what a DataGridView looks like. That doesn't change the fact that, if you want to populate multiple columns, you need to pass multiple values when calling Rows.Add.
yes, im biggener in vb.net
and , ineed help
thanks
-
Aug 3rd, 2020, 07:59 PM
#8
Re: how to get webbrowser GetElementById to datagridview1
Help to what? You know how to add a row. I told you that, if you want that row to have three values, you need to pass three values to the method that adds a the row. Have you tried that? Have you tried testing it with literal values to confirm that it works? If not, why not? Do you know what the three values are that you want in each row? If you would like our help getting those values, have you considered explaining what they are? You want help parsing an HTML document that you've never shown us. Maybe that's something to consider. If you expect someone to help you parse some data, some people might think that it would be a good idea to provide a simple example of that data.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|