Hi Armin,
Well I created my own ErrorProider like this....
Public Class MojoErrorProvid er
Inherits System.Windows. Forms.ErrorProv ider
#Region " Component Designer generated code "
Public Sub New(ByVal Container As System.Componen tModel.IContain er)
MyClass.New()
'Required for Windows.Forms Class Composition Designer support
Container.Add(M e)
End Sub
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeCompo nent()
'Add any initialization after the InitializeCompo nent() call
End Sub
'Component overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
'Required by the Component Designer
Private components As System.Componen tModel.IContain er
'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r
End Sub
#End Region
Private _errorList As New ArrayList
Private _activeControl As Control
Public Shadows Sub SetError(ByVal control As Control, ByVal value
As String)
If value = "" Then
If _errorList.Cont ains(control) Then
_errorList.Remo ve(control)
End If
Else
If Not _errorList.Cont ains(_errorList ) Then
_errorList.Add( control)
End If
End If
MyBase.SetError (control, value)
End Sub
Public Shadows Sub SetError(ByVal value As String)
If _activeControl Is Nothing Then
Throw New Exception("Acti ve control has not been set.")
End If
Call Me.SetError(_ac tiveControl, value)
End Sub
Public Sub ClearError(ByVa l control As Control)
If _errorList.Cont ains(control) Then
_errorList.Remo ve(control)
End If
MyBase.SetError (control, "")
End Sub
Public Sub ClearError()
If _activeControl Is Nothing Then
Throw New Exception("Acti ve control has not been set.")
End If
Call Me.ClearError(_ activeControl)
End Sub
Public Sub ClearAll()
For Each control As control In _errorList
MyBase.SetError (control, "")
Next
_errorList.Clea r()
End Sub
Public Function HasErrors() As Boolean
Return _errorList.Coun t > 0
End Function
End Class
So now I have the functionality I wanted.
:o)
Thanks for helping me out!
M O J O
Armin Zingler wrote:
"M O J O" <mojo@_no_spam_ delete_this_new websolutions.dk > schrieb
Well if I have 30 controls on my form, then the ....
If err.GetError(Me .TextBox1).Leng th > 0 Or _
err.GetError(Me .TextBox2).Leng th > 0 Or _
err.GetError(Me .TextBox3).Leng th > 0 Or _
err.GetError(Me .TextBox4).Leng th > 0 Or _
..
..
err.GetError(Me .TextBox30).Len gth > 0 Or Then
MsgBox("HAS ERROR")
End If
Why not put the textboxes in an array once, later use a loop?