Ticket Q511579
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Validation - Check validation rules when input focus changes

Validate after user enter value and prevent switching next control

created 12 years ago

Hello!
Is it possible to do this?
I want to validate immediately after user enter values and if it's wrong I want to prevent switching to next control until user corrects the value.

Thanks in advanced!

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hello Joao,
It is possible to implement this scenario with custom code. Let me describe the main steps below:

  1. Access required editors as described at Access Editor Settings and handle their System.Windows.Forms.Control.Validating or other similar events.
  2. In the event handler, manually perform validation as described at http://documentation.devexpress.com/#Xaf/CustomDocument3010
    I hope you find this information helpful.
    Show previous comments (9)

      Thanks for the help.
      I'm having some problems implementing the solution above and some questions.
      1: The columns for the view aren't created in "CreateControlsCore" and "AssignDataSourceToControl" so I can't assign the lookup to any column. Do I need to create all the columns for the view or it creates automatically?
      2: For each lookup that I want to create I need to query database or there is an automatic way to do this?
      Thanks again!

      Dennis Garavsky (DevExpress) 11 years ago

        Hello Joao,
        Thank you for the update. Please give us some additional time to research your project. We will get back to you with a solution as soon as we can.

        Dennis Garavsky (DevExpress) 11 years ago

          Hello Joao,
          A1: You can either create all the columns yourself or customize the auto-generated columns when they are created. I have attached a modified version of your ListEditor that demonstrates the latter approach. Take special note of the OnColumnsCreated method there.
          A2: Yes, you need to create and initialize each look as described in the XPO and XtraGrid documentation. Refer to the How to: Bind an XPCollection to a LookUp article for more details. Please contact our XtraGrid team in you have any questions on customizing the grid control as you want, because it is not directly related to our framework. In general, I believe that it may be much easier for you to accomplish this task as follows:

          1. Design a custom user control based on the grid control at design time in Visual Studio and by using only XtraGrid approaches;
          2. Once you have your custom user control working as you expect, put this custom control into a custom ListEditor. Your custom user control should have a method to accept a data source and this method can then be called from within your custom ListEditor's AssignDataSourceToControl method.
            P.S.
            You may also find the source code of the default GridListEditor helpful: …\DevExpress.ExpressApp.Win\Editors\Grid\GridListEditor.cs

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.