Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clicking on an ErrorProvider

Status
Not open for further replies.

Becks25Not

Programmer
Jun 23, 2004
176
US
Hi All,

I am using an error provider. I am having the problem that when you click on it, it no longer shows the tooltip. There is not an on click event to prevent this from happening. I tried resetting the error provider in the form's click event but that did not work. Any ideas?

Thanks!!
Becca
 
Not perfect, but this is as close as I can get to what you are looking for:

Code:
	Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave

		If TextBox1.Text <> "Fred" Then
			ErrorProvider1.SetError(TextBox1, "You must type Fred")
		Else
			ErrorProvider1.SetError(TextBox1, "")
		End If

	End Sub


	Private Sub TextBox2_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Leave

		If TextBox2.Text <> "Fred" Then
			ErrorProvider1.SetError(TextBox2, "You must type Bloggs")
		Else
			ErrorProvider1.SetError(TextBox1, "")
		End If

	End Sub

	Private Sub Form3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

		For Each ctrl As Control In Me.Controls
			If ErrorProvider1.GetError(ctrl) <> "" Then
				Dim s As String = ErrorProvider1.GetError(ctrl)
				ErrorProvider1.SetError(ctrl, "")
				ErrorProvider1.SetError(ctrl, s)
			End If
		Next

	End Sub

Simply resetting the error, as you say, doesn't seem to work, however, I save the text associated with the control's error provider, then clear the error and then reset the error - which seems to do the trick (but does, of course, require clicking on the form). You could also use the same code in a button (btnReShowErrors).


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top