Ticket T736619
Visible to All Users

XtraTabControl - Controls aren't validated when placed on invisible tab pages

created 6 years ago

[DevExpress Support Team: CLONED FROM T302940: DXValidation Not working on controls that are behind a tabbed group control]
Hello,

I am having same issue with my WinForm App with XtraTabControl.

I have nested Tab Controls, each with multple pages. As suggested, I looped through TabPages of each control and programmatically set them to be SelectedPage. But the validation still fails. Validation works only on page which is made to be selected page LAST in the loop. I tried putting  Application.DoEvents() also but it did not help.

Here is my function which accepts XtraTabControl and loops through its pages. Do I need to do something else.

Also, if I click that particular page where validation fails, manually, the validation works!!

C#
private void ActivateTabPage(XtraTabControl tabControl) { //This Loop is required so that databinding will take effect on hidden tab pages (which does not unless tabpage is activated) and Validation will happen correctly //https://www.devexpress.com/Support/Center/Question/Details/T302940/dxvalidation-not-working-on-controls-that-are-behind-a-tabbed-group-control foreach (XtraTabPage tabPage in tabControl.TabPages.Where(p => p.PageVisible)) { tabControl.SelectedTabPage = tabPage; //Application.DoEvents(); } if (tabControl.TabPages.Count(p => p.PageVisible) > 0) { int minIndex = tabControl.TabPages.Where(p => p.PageVisible)?.Min(p => p.TabIndex) ?? -1; if (minIndex >= 0) tabControl.SelectedTabPage = tabControl.TabPages[minIndex]; } }
Comments (2)
DevExpress Support Team 6 years ago

    Your code looks correct to me. It is difficult to give you a precise answer about the cause of the issue without reproducing this problem on our side.
    There may be a lot of different factors that affect the problem. Would you please send me a sample where you faced the problem so I can thoroughly research it and help you?
    Your time and cooperation are greatly appreciated.

    VM VM
    Vishwas Mokashi 6 years ago

      Hello Stas,

      Here is the sample.

      1. Run and Click on Validate Invoice button on xtraTabPage1
      2. It will validate controls on xtraTabPage2 >> xtraTabPage4
      3. Validation is failing as Quantity is 0. (despite validation rule being GreaterThanEqual to 0
      4. If you manually activate xtraTabPage2 >> xtraTabPage4 and click Validate Invoice button on xtraTabPage1, then validation is succesful

      Problem is despite looping through all the tabPages, it requires me to click the xtraTabPage4 manually for correct validation.

      Answers approved by DevExpress Support

      created 6 years ago (modified 6 years ago)

      This behavior takes place because you make pages in TabControls visible in the order. As a result, the page is switched in xtraTabControl2  when this control is invisible. As a result data bindings aren't initialized.
      To resolve this issue, you can check whether there are child TabControls on a page and pass them to the ActivateTabPage method recursively.
      I've modified your sample to demonstrate how this works.

        Comments (1)
        VM VM
        Vishwas Mokashi 6 years ago

          thanks Stas, it works now…

          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.