25

I have some custom/user controls that in most cases have label and entry, like this:

removed dead ImageShack link

Is there any way I can customize the standard WinForms ErrorProvider to display its icon inside entry (entry - textbox, combo, datetime etc...), like this:

removed dead ImageShack link

where the red circle is of course the error indicator.

Thanks for any help.

SuperBiasedMan
  • 9,814
  • 10
  • 45
  • 73
Jarek
  • 5,885
  • 6
  • 41
  • 55

1 Answers1

55

I've found a solution:

this.errorProvider.SetIconPadding(this.textBox, -20);

where errorProvider is an ErrorProvider Object and textBox is an Entry object.

Jarek
  • 5,885
  • 6
  • 41
  • 55
  • 7
    not sure how good this is, but for me a possible solution to the magic number is: `errorProvider.Icon.Width + textBox.Bounds.Width - textBox.ClientRectangle.Width`. Of course the icon size *should* be appropriate to the `textBox.Height` but that's often the case (16x16 icon, textBox default height is 20) – Jonno Jun 21 '12 at 07:08