[RESOLVED] Applying a condition
I have add,update,delete buttons on my form.A message box should appear on the screen "should have values to Add/delete/update/" if user clicks on Add/delete/update buttons without having any values in the textfiled,i have around 20 text fields on my form.
Re: [RESOLVED] Applying a condition
Re: [RESOLVED] Applying a condition
If you want, you can add ctrl.Name to the messagebox and tell them which textbox needs to be addressed and then set focus to it.
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ctrl As Control = Me.GetNextControl(Me, True)
Do
If TypeOf ctrl Is TextBox Then
If ctrl.Text = String.Empty Then
MessageBox.Show(ctrl.Name & " is empty. All entires must be complete before running the query.", "Can't Execute Query", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
ctrl.Focus() 'set focus to the empty textbox
Exit Do
End If
End If
ctrl = Me.GetNextControl(ctrl, True)
Loop Until ctrl Is Nothing
End Sub