Prawie dziala.
Ucze sie "obiektow" bylbym wdzieczny za poprawienie albo zaproponowanie rozwiazania. Ewentualnie z radoscia przyjme korepetycje zdalne z osoba ktora dobrze to rozkminila.
Na formie 3 textboxy:
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As WindowsApplication1.CustomTextBox
Friend WithEvents TextBox3 As WindowsApplication1.CustomTextBox
Public Class Form1
Private Sub TextBox1_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If TextBox1.Text = "" Then
e.Cancel = True
ErrorProvider1.SetError(TextBox1, "Wpisz dane aby kontynuowac.")
End If
End Sub
Private Sub TextBox1_Validated(sender As System.Object, e As System.EventArgs) Handles TextBox1.Validated
ErrorProvider1.SetError(TextBox1, "")
End Sub
End Class
Public Class CustomTextBox : Inherits TextBox
Public Sub New()
MyBase.BackColor = Color.Green
End Sub
'Ta funkcja dziala
'Private Sub MyCustomTextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles Me.TextChanged
' MsgBox("aa")
'End Sub
Private Sub MyCustomTextBox_Validating(sender As System.Object, e As System.EventArgs) Handles Me.Validating
If MyBase.Text = "" Then
'Cancel' is not a member of 'System.EventArgs'.
'e.Cancel = True
Form1.ErrorProvider1.SetError(sender, "Wpisz dane aby kontynuowac.")
End If
End Sub
End Class
CustomTextBox sa zielone, i jak nie wpiszemy nic w nie to pojawia sie ikonka walidacji. Problem jest zeby przechwydzic e.cancel
Cel: chcialbym zrobic wspolna walidacje. Taka jak w standardowym checkboksie.