Manipulating Controls On Parent Forms From Child VB.NET - vb.net

I'm trying to add a new row to a DataGridView from FORM 2 but I can not succeed, the code I tried is as follows:
FORM 2:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FORM1.invoice_items.Rows.Add()
End Sub
Looking like it took time but can not find a solution, someone who can help me with my problem would be nice, Thank You.

Try this
This work only if you use a showdialog.
Form 2 :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Pass the value to be added in the datagrid to form 1
Me.DialogResult=Windows.Forms.DialogResult.OK
End Sub
Form 1:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Form2.ShowDialog = Windows.Forms.DialogResult.OK Then
'Getthe value from form 2
invoice_items.Rows.Add()
End If
End Sub

Related

How Do I Click This Button? In Visual Basic 2010 WebBrowser control

I am trying to click this button in WebBrowser Control
Im trying to make a web automation to purchase from gamestop im using visual basic 2010 express heres what my code looks like
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("mainContentPlaceHolder_dynamicContent_ctl00_RepeaterResultFoundTemplate_ResultFoundPlaceHolder_1_ctl00_1_ctl00_1_StandardPlaceHolderTop_3_ctl00_3_rptResults_3_res_0_btnAddToCart_0").InvokeMember("Click")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Navigate("http://www.gamestop.com/browse?nav=16k-3-wwii,28zu0")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Document.GetElementById("cartcheckoutbtn").InvokeMember("Click")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
WebBrowser1.Document.GetElementById("buyasguest").InvokeMember("Click")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
WebBrowser1.Document.GetElementById("ShipTo_FirstName").SetAttribute("value", "Rob")
WebBrowser1.Document.GetElementById("ShipTo_LastName").SetAttribute("value", "Horton")
WebBrowser1.Document.GetElementById("ShipTo_City").SetAttribute("value", "San Diego")
WebBrowser1.Document.GetElementById("USStates").InvokeMember("Select")
WebBrowser1.Document.GetElementById("ShipTo_Line1").SetAttribute("value", "9295 PebbleStone Ln")
WebBrowser1.Document.GetElementById("ShipTo_PostalCode").SetAttribute("value", "92128")
WebBrowser1.Document.GetElementById("ShipTo_PhoneNumber").SetAttribute("value", "6194682282")
For Each ee As HtmlElement In WebBrowser1.Document.All
If ee.InnerText Is Nothing Then Continue For
If ee.InnerText = "California" Then ee.SetAttribute("Selected", True)
Next
WebBrowser1.Document.GetElementById("ShipTo_EmailAddress").SetAttribute("value", TextBox1.Text)
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If element.GetAttribute("class") = "btn_positive ats-checkoutbtn" Then
element.InvokeMember("click")
End If
Next
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Im trying to click on this button and i inspect elemented it and this is what showed up **
(CONTINUE CHECKOUT ▶)
**
How Do I make it click this i tried Id but it has no id
btw im new to this just trying to make a auto web automation software to purchase games The code thats there when i inspect element it is on the top top top
You are actually trying to click a link and not an input button.
The link has an onclick attribute that contains javascript and returns false.
So you can either find that link or you can just execute the Javascript that the link executes submitshipto()
WebBrowser1.InvokeScript("submitshipto()")
Or:
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("a")
If element.GetAttribute("class") = "btn_positive ats-checkoutbtn" Then
element.InvokeMember("click")
End If
Next

How can I create a TableLayoutPanel in VB Dynamically?

I'm trying to make a tableLayoutPanel by code in Windows Form VB which can later be coded to add on extra rows and columns also by coding
When the form starts:
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _MyBase.Load
Dim TLP As New TableLayoutPanel
'Edit all your properties: name, size, location, etc.
End Sub
Say when you click a button1:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Controls.Add(TLP)
End Sub
Hope that helps.

how do i save time in datagridview in vb.net 2010 [Newbie student]

Example i press start time and the time connected in textbox that it will show when i start the time same with out time,and when i press save it wont add to datagridview. Please help me with my problem. This is my save code:
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Table1BindingSource.AddNew()
Me.Validate()
Me.Table1BindingSource.EndEdit()
Me.Table1TableAdapter.Update(Me.OpenDataSet.Table1)
End Sub
Ok, I solved your problem....
Here is how your form should look like :
And now you need to add the "Time" columns to the datagridview:
And now... follow my steps through the image:
and here is the code :
Public Class Form1
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Table1BindingSource.Rows.Add()
Table1BindingSource.Rows(Table1BindingSource.Rows.Count - 1).Cells(0).Value = TextBox1.Text & Table1BindingSource.Rows.Count
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CountTimer.Tick
TextBox1.Text += 1
End Sub
End Class
I Hope My Answer Was Useful To You :)

Insert,update delete in vb.net

I edited my question and heres the whole code i used
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'GradesDBDataSet.tblGrades' table. You can move, or remove it, as needed.
Me.TblGradesTableAdapter.Fill(Me.GradesDBDataSet.tblGrades)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TblGradesBindingSource.MoveNext()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
TblGradesBindingSource.RemoveCurrent()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TblGradesBindingSource.MovePrevious()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
TblGradesBindingSource.MoveLast()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TblGradesBindingSource.MoveFirst()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TblGradesBindingSource.AddNew()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
On Error GoTo saveErr
TblGradesBindingSource.EndEdit()
TblGradesTableAdapter.Update(GradesDBDataSet.tblGrades)
MsgBox("Record Save ", MsgBoxStyle.Information)
saveErr:
Exit Sub
End Sub
End Class
Hello Everyone... i have a problem using this code. . to save data to ms access from vb.net
i just follow a tutorial in youtube. it works BUT when i close the program then minutes later I run it again, data doesnt saved. . . Why? .
And can you suggest whats is the best way to Add, DELETE SAVE using vb.net? thanks eveyone ^_^
The most likely answer is that you are using a local data file that is overwritten each time you build.
Read this to learn how local data files are managed:
http://msdn2.microsoft.com/en-us/library/ms246989(VS.80).aspx
The solution in that case is to select the data file in the Solution Explorer, open the Properties window and set the Copy to output directory property to Copy if newer. The source file will only be copied to the output folder if you have changed that source file. That means that you can keep your test data between sessions.

vb.net RDLC report doesn't show report when button is clicked

In my Vb.net application I use rdlc report and ReportViewer. But it only loads report in the page_load event.
Here is my code
Private Sub report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.displayTableAdapter.Fill(Me.aludbDataSet.display)
Me.ReportViewer1.RefreshReport()
End Sub
When I change it to Button_click event, it doesn't load the report. Code is here
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.displayTableAdapter.Fill(Me.aludbDataSet.display)
Me.ReportViewer1.RefreshReport()
End Sub
I don't know why this happened. Because both are same code, only the way is different. Now, I want to load the report when the button is clicked. How to do that? Anyone help please. Thanks
try adding the "Handles" code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click