Delete Button Codes - vb.net

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 'Material_Status_DBDataSet.Material_Status_Table' table. You can move, or remove it, as needed.
Me.Material_Status_TableTableAdapter.Fill(Me.Material_Status_DBDataSet.Material_Status_Table)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'add
PL_NOTextBox.Enabled = True
NAME_OF_THE_JOBTextBox.Enabled = True
QUANTITYTextBox.Enabled = True
ITEMTextBox.Enabled = True
UNITTextBox.Enabled = True
REMARKSTextBox.Enabled = True
ACTION_TAKENTextBox.Enabled = True
Me.Material_Status_TableBindingSource.AddNew()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'delete
Me.Material_Status_TableBindingSource.RemoveCurrent()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'edit
PL_NOTextBox.Enabled = True
NAME_OF_THE_JOBTextBox.Enabled = True
QUANTITYTextBox.Enabled = True
ITEMTextBox.Enabled = True
UNITTextBox.Enabled = True
REMARKSTextBox.Enabled = True
ACTION_TAKENTextBox.Enabled = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'update
Me.Validate()
Me.Material_Status_TableBindingSource.EndEdit()
Me.Material_Status_TableTableAdapter.Update(Me.Material_Status_DBDataSet)
TableAdapterManager.UpdateAll(Me.Material_Status_DBDataSet)
PL_NOTextBox.Enabled = False
NAME_OF_THE_JOBTextBox.Enabled = False
QUANTITYTextBox.Enabled = False
ITEMTextBox.Enabled = False
UNITTextBox.Enabled = False
REMARKSTextBox.Enabled = False
ACTION_TAKENTextBox.Enabled = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
'search Me.Material_Status_TableTableAdapter.SearchPLNO(Me.Material_Status_DBDataSet.Material_Status_Table, TextBox1.Text)
End Sub
End Class
Hello, I am new to vb. My project has an add, delete & update search buttons that connect with a database called material status. When I run this project it don't permanently delete data record in database enter image description here , when delete button pressed. What is wrong here?
Could you please send me codes for display searching combo box instead of textbox1.

Related

How do I get the parent form from a child form in VB.net?

I have a VB form which may be called by a number of forms. Upon exiting this child form, I want to restore the calling form but I cannot seem to figure out how to determine which form called it. Any help would be greatly appreciated.
You can create a tagging for parent forms (maybe a global array) which you will update the value every time you open a child form. You just have to remember which form is which on the tagging you will make.
Maybe you can try this-
Module with form tagging:
Module Module1
Public parentForms(2) As String
'parentForms(0) - parent form of Form 1
'parentForms(1) - parent form of Form 2
'parentForms(2) - parent form of Form 3
Public Sub openParentForm(ByVal ParentTag As String)
If ParentTag {use the notequal operator} "" Then
Select Case ParentTag
Case Form1.Tag
Form1.Show()
Case Form2.Tag
Form2.Show()
Case Form3.Tag
Form3.Show()
End Select
End If
End Sub
End Module
Form1:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Tag = "Form1"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
parentForms(1) = Me.Tag
Form2.Show()
'Dont use .Close as the Parent Form will be disposed and the whole application will exit
Me.Visible = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
parentForms(2) = Me.Tag
Form3.Show()
Me.Visible = False
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Call openParentForm(parentForms(0))
End Sub
End Class
Form2
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Tag = "Form2"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
parentForms(0) = Me.Tag
Form1.Show()
Me.Visible = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
parentForms(2) = Me.Tag
Form3.Show()
Me.Visible = False
End Sub
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Call openParentForm(parentForms(1))
End Sub
End Class
Form3
Public Class Form3
Private Sub Form3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Tag = "Form3"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
parentForms(0) = Me.Tag
Form1.Show()
Me.Visible = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
parentForms(1) = Me.Tag
Form2.Show()
Me.Visible = False
End Sub
Private Sub Form3_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Call openParentForm(parentForms(2))
End Sub
End Class

how to if combobox selection then directly checkbox unchecked in vb.net

How if ComboBox selection then directly CheckBox unchecked?
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Me.TextBox1.Text = ""
Me.PopulateDataGridView()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
clearfiltercombobox()
PopulateDataGridView()
End Sub
Put Me.CheckBox1.Checked = False in your ComboBox handler
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
Me.TextBox1.Text = ""
Me.CheckBox1.Checked = False
Me.PopulateDataGridView()
End Sub

How can I increase the font size of the user's input by one every 2 seconds in the code below?

Public Class Form1
Dim mypicturebox As New PictureBox
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "hello " & TextBox1.Text
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Me.Label1.Text = "enter your name"
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mypicturebox.BackColor = Color.Red
mypicturebox.Width = 50
mypicturebox.Height = 50
mypicturebox.Left = 100
mypicturebox.Top = 100
Me.Controls.Add(mypicturebox)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim MyFont As New Font(TextBox1.Font.FontFamily, 12, FontStyle.Bold)
Dim size As Integer = 30
Me.Font = New Font(Me.Font.FontFamily, size)
Label1.Font = New Font(Label1.Font.FontFamily, size)
Label1.Font.Size = Label1.Font.Size + 1
End Sub
End Class
When I run the code, it says that the font size is read-only so I cannot change it.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 2000 '2 sec
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox1.Font = New Font(TextBox1.Font.FontFamily, TextBox1.Font.Size + 1)
End Sub

VB.net Form unexpectingly terminating

Hi I have the following form but cant figureout why its upbrubtly terminiating when difrent buttons are clicked?
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub button1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
Dim TEST1 As Integer = System.IO.Directory.GetFiles("C:\test\test").Length
If TEST1 = 0 Then
Me.WebBrowser1.Navigate("http://www.hotmail.com")
End If
End Sub
Private Sub button1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave
Me.WebBrowser1.Navigate("http://WWW.facebook.com")
End Sub
Private Sub button2_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.MouseLeave
Me.WebBrowser1.Navigate("http://WWW.facebook.com")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.WebBrowser1.Navigate("file://C:\test\test")
Button1.Enabled = False
Button2.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.WebBrowser1.Navigate("file://C:\test")
Button2.Enabled = False
Button1.Enabled = True
End Sub
Private Sub button2_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.MouseEnter
Dim TEST2 As Integer = System.IO.Directory.GetFiles("C:\test\test").Length
If TEST2 = 0 Then
Me.WebBrowser1.Navigate("http://www.hotmail.com")
End If
End Sub
The terms face book and hotmail are just random to keep company site private :)
I suspect the Mouse_Enter event and the Mouse_Leave events are not giving time to the webbrowser to fully load the document and maybe it is internally crashing.
Try checking if the webbrowser has finished working before navigating again and tell us:
Use
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Me.WebBrowser1.Navigate("http://www.google.com")
End if

how disable text box from two give text box?

I have 2 text box in one vb form. if txtMaterial was fill i want to disable the txtPackage and vice versa. I use the code below, but it didn't work. could someone fixed it.
Really appreciate it. tq.
Private Sub txtMaterial_TextChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMaterial.TextChanged
txtMaterial.Enabled = True
txtPackage.Enabled = False
End Sub
Private Sub txtPackage_TextChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPackage.TextChanged
txtPackage.Enabled = True
txtMaterial.Enabled = False
End Sub
Make both TextBoxes fire the same handler, then simply set the Enabled() state of each one based on whether the other TextBox has something in it:
Private Sub txtChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMaterial.TextChanged, txtPackage.TextChanged
txtMaterial.Enabled = (txtPackage.TextLength = 0)
txtPackage.Enabled = (txtMaterial.TextLength = 0)
End Sub
*Note the ending of the first line has both controls listed using Handles txtMaterial.TextChanged, txtPackage.TextChanged at the end.
Private Sub txtMaterial_TextChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMaterial.TextChanged
If txtMaterial.Text <> "" Then
txtPackage.Enabled =False
End If
End Sub
based on the comment that you added
Blockquote i want to make it disable as the second one. but in my case if i fill the txtMaterial the txtPackage also can be fill with text at the same time.
the solution to your problem must be this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtPackage.Enabled = False
End Sub
Private Sub txtMaterial_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMaterial.TextChanged
If Not String.IsNullOrEmpty(txtMaterial.Text) Then
txtPackage.Enabled = True
Else
txtPackage.Enabled = False
End If
End Sub