ErrorProvider not showing ampersand

G

Guest

I'm using an ErrorProvider to display validation info on a simple text-box.
I need to be able to let users know that they cannot use certain characters.
One of the characters is an ampersand (&). The problem I have is that the
tool-tip for the errorprovider won't show ampersands. I'm guessing this is
because the tooltip.StripAmpersands property is set to true for the tooltip.
I can't figure out how to change this. Any Suggestions?
 
B

Bruce Wood

sprice said:
I'm using an ErrorProvider to display validation info on a simple text-box.
I need to be able to let users know that they cannot use certain characters.
One of the characters is an ampersand (&). The problem I have is that the
tool-tip for the errorprovider won't show ampersands. I'm guessing this is
because the tooltip.StripAmpersands property is set to true for the tooltip.
I can't figure out how to change this. Any Suggestions?

Have you tried doubling the ampersands? That is, substituting && for
each &?

This works for the Label control... I don't know about tool tips.
 
R

rsine

Sprice,

I got this to work:

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = "&" Then
ErrorProvider1.SetError(TextBox1, String.Format("Cannot
enter {0} in textbox", "&&&"))
e.Handled = True
End If
End Sub
 
G

Guest

Thanks a lot, this worked fine. I had tried the double ampersand, but I
hadn't tried the triple. So three ampersands shows up as one in an
ErrorProvider. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top