Ticket T302940
Visible to All Users

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

created 9 years ago

I have some lookup edit controls on tab 2 of a grouped tab control. When I load the form I do iterate programatically through the tabs so the controls are properly binded. The problem I am having is that when the user clicks the save button the controls on tab 2 do not validate unless the user has tab 2 selected and the lookup edit controls are visible. I read something about making the controls visible programatically in the form shown event but that doesn't seem to be working for me. Can you please help me out. Thanks

Comments (3)
Andrew Ser (DevExpress Support) 9 years ago

    Hello,
    It is a WinForms specific that the control bindings are completely initialized only when they become visible for the first time. Possibly, manually creating a BindingContext for invisible controls may resolve the issue. I cannot say for sure because it is unclear how you are forcing the controls to be validated. Are you using our DXValidationProvider? Are you validating controls in the Validating event? This information will allow us to suggest an appropriate solution faster.
    I hope to receive your response soon.

      I am validating the controls using the DXvalidation provider. I validate on the save button click event.
      ie. dxValidationProvider1.Validate()
      All of the other controls on the form are also validated using the validation provider control. Those ones work correctly because they are always visible (not hidden behind a tab) on the form. Validation however isn't working on controls that are not visible. If I click on tab 2 making the lookup edit controls visible and then click save they validate fine. Validation is not occurring when the controls are not visible to the user.

      Andrew Ser (DevExpress Support) 9 years ago

        Hi,
        Thank you for the clarification. I've reproduced this issue with LookUpEdits. We need more time to research it. We will update this ticket soon.

        Answers approved by DevExpress Support

        created 9 years ago (modified 9 years ago)

        Hello Mike,
        Any property of any control cannot be bound to a property of any other object until a handle of this control is created. A handle is created when the control is going to be visible for the first time. After that, the control updates its data bindings. This is default behavior powered by Microsoft and doesn't relate to our components.
        To resolve this issue, you can iterate through each page in the page collection and sequentially select each of them.
        For example, you can handle the Form.Load event and use the following code in the event handler:

        C#
        foreach (XtraTabPage page in XtraTabControl.TabPages) XtraTabControl.SelectedTabPage = page; XtraTabControl.SelectedTabPage = XtraTabControl.TabPages[0];

        I hope this information is helpful. Let me know if you have additional questions.

          Show previous comments (4)
          DevExpress Support Team 9 years ago

            Hello Mike,
            Thank you for the project and clarification.
            In this case, use this code:

            C#
            foreach (LayoutGroup page in TabbedControlGroup.TabPages) TabbedControlGroup.SelectedTabPage = page; TabbedControlGroup.SelectedTabPage = TabbedControlGroup.TabPages[0];

            I've also modified my project to demonstrate how this works. Let me know if you have additional questions.

            VM VM
            Vishwas Mokashi 6 years ago

              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]; } }
              DevExpress Support Team 6 years ago

                Hello,
                To avoid any misunderstanding, I've created a separate **XtraTabControl - Controls aren't validated when placed on invisible tab pages**ticket on your behalf. Please refer to it for further discussion.

                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.