Search code examples
c#.netwinformsui-automationmicrosoft-ui-automation

MS UI Automation WinForms: Can't find grid field chooser window on UIA automation tree


We have an Infragistics UltraGrid control, and you can show a field chooser window for that grid.

Field chooser shown

However, the field chooser doesn't show up on the UIA automation tree. If I try searching for it programmatically then UIA doesn't find it, same if I try to manually look for it using UIA Verify.

Automation tree doesnt show field chooser

But if I use UIA Verify hover/focus mode to find the field chooser, then it shows it, and also shows it under the same form as the grid control.

enter image description here

How do I find the control using code? Why doesn't it show up on the automation tree?


Solution

  • This appears to be a bug in the .NET framework related to forms created from MDI child forms. As a workaround, I've been able to use the AutomationElement.FromPoint() function.

    Microsoft forum link

    Quoting from Guy Barker (Microsoft):

    "I can reproduce the issue you’re seeing. I set the main to be a mdi container, and created a child form, whose MdiParent is the main form. I then added the original owned form as owned by the mdi child form. When I did this, I could get the details of the owned form in Inspect, but the form didn’t appear in the UIA tree view.

    Interestingly, when I view the ancestors of the owned form, it lists the mdi child form as the parent as expected. But for some reason, the mdi child form doesn’t consider the owned form to be one of its children.

    I don’t have any suggestions as to how to workaround this at the moment, but I’ll post a comment here if I do find something."