Customizing WinForms ErrorProvider to display its icon inside control's entry
Asked Answered
M

1

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.

Model answered 15/7, 2009 at 20:48 Comment(0)
M
55

I've found a solution:

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

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

Model answered 16/7, 2009 at 21:25 Comment(1)
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)Mansized

© 2022 - 2024 — McMap. All rights reserved.