
When using the ResourceManager's GetString() method, you can receive the correct localized string. Name it this way, Res.XX.resx, where the XXs are you language you're writing strings for, e.g. When using the ResourceManager, you add a resource file. class NewUserControl : ErrorProviderĪnother option is to use the ResourceManager. Then you provide an Enable() method which calls SetError with the local string and displays the icon. The new user control holds the local error descriptor string, which you can change whenever you'd like to without displaying the icon. One neat and clean solution is to create a user control that inherites the ErrorProvider. Fortunately there are multiple options to come around this. In many applications it is evident to provide error descriptors in different languages, but when you cannot set the descriptor in whatever language without displaying the icon, you face additional work. Elsewhere its either a Start() method, Enable() method etc.īy combining a string with control display features it is difficult to use localization. Net framework that uses this "mechanism". Why do you have to set a 'string' to display an icon?! I don't get it. But, there is something that bothers every time I'm using this control. This is a very useful control for providing non-intrusive feedback to the user. This displays the error symbol next to the control. if (!validUserInput(textBox.Text))ĮrrorProvider1.SetError(this, "Invalid user input") Whenever the control's state is invalid, you set the error description string, by using the SetError method on the ErrorProvider control. IconPadding: The extra space between the error icon and the control.IconAlignment: Where the icon should be placed relative to the control.Icon: The icon that is displayed when the error description string is set.BlinkStyle: This property can have one of the following values, AlwaysBlink, BlinkIfDifferentError or NeverBlink.BlinkRate: This is the rate in milliseconds with which the icon will blink.To modify the behavior, you can set the following properties: You can either drag the control from the ToolBox or you can programatically create an instance of the ErrorProvider. Hovering the mouse over the icon, a tooltip will display the error description string. If the error description string is set, an icon will appear next to the control. Net framework also provides a control named ErrorProvider, which is a control you can attach to any control that needs validation logic. Other approaches could be a balloon message, using the status panel or giving an audio clue of the invalid input. Having several controls that needs user input this approach can be both cumbersome and intrusive for the user. A MessageBox can then provide the reason and remedies in the popup dialog box. You can use a MessageBox to indicate that the state of the control is not valid. Net framework provides several mechanisms for indicating invalid user inputs. ErrorProvider providing localization difficulties
