' Implements the IDXDataErrorInfo.GetPropertyError method. Private void Form1_Load(object sender, EventArgs e) ' field cannot be empty", propertyName) The editors contain empty strings, and as a result error icons are displayed within the editors: The following image illustrates the resulting form after it has been opened at runtime. In this example, the DXErrorProvider.DataSource property is set to the BindingSource. To automatically track errors supplied by a data source, the DXErrorProvider component must be bound to this data source via the DXErrorProvider.DataSource property. It indicates errors as error icons, which can be hovered over to display error text. To display the supplied errors within the editors, a DXErrorProvider component needs to be added to the form. The MyRecord class implements the IDXDataErrorInfo interface and returns the error information via the IDXDataErrorInfo.GetPropertyError method. In this example, the error information is provided on the data source level. The requirement is to visually indicate errors within the editors, if the record’s FirstName or LastName property contain an empty string. This class’ records are stored in a BindingSource component and edited using text editors (the FirstName and LastName properties are edited in a textEdit1 and textEdit2 controls respectively). It contains two properties ( FirstName and LastName) that cannot be empty. In this example, the business object is represented by a custom MyRecord class. Error information will be handled by the DXErrorProvider component, which will indicate any error to an end-user. The following example demonstrates how to implement error notifications for a custom business object at the data source level, using the IDXDataErrorInfo interface. Hovering over the error icons displays the supplied error text. If a business object’s properties are edited in Developer Express editors (for example, a TextEdit, SpinEdit, etc) and errors are set via the IDXDataErrorInfo interface, the DXErrorProvider will track the errors and indicate them by displaying error icons within the editors. To track errors, the DXErrorProvider must be bound to the business object, or to a collection of business objects via the DXErrorProvider.DataSource property. Errors supplied via this interface are handled by a DXErrorProvider component. Public interface IDXDataErrorInfo Public Interface IDXDataErrorInfo RemarksĪ business object can implement the IDXDataErrorInfo interface to indicate if any property contains an invalid value, and as a result provide error information for these properties.
0 Comments
Leave a Reply. |