Hi,
I'm trying to use Microsoft UIA to show and hide fields on the UltraGrid.
I can show the field chooser (by simulating a mouse click on the field chooser button). But I am having trouble retrieving the AutomationElement for the field chooser window.
The problem is that it doesn't appear in the Automation Elements Tree. Neither if I try viewing the tree in Visual UI Automation Verify or if I try and find the field chooser using UIA functions.
If I use focus mode to find the control from the Visual UI Automation Verify tool then it shows it on the tree, under the same form as the grid.
Do you have any idea how to access the field chooser using UIA?
Thanks in advance.
Glad you were able to gain access to the AutomationElement. The fact that the ColumnChooserDialog is displayed within the bounds of the parent UltraGrid is just luck and how your application is designed. The dialog is displayed using the FormStartPosition of WindowsDefaultLocation, so it is just being displayed in the next valid cascade position. If you are manually calling ShowColumnChooser() as your sample demonstrates, I suggest using the ShowColumnChooser() overload that allows you to specify the bounds of the column chooser. This will allow you to know exactly where the dialog is.
Let us know if you need any further assistance.
Chris
Ok, that makes sense.
I was able to workaround it by scanning the screen using AutomationElement.GetPoint() to find the field chooser. I jump around in 200 pixel increments within the bounds of the parent UltraGrid control (it seems as though the field chooser always initially appears within the parent Ultragrid).
Hello,
Not sure there is much that can be done here. This looks like a bug in the .NET framework. It appears that forms that are owned by an MdiChild form are not properly placed in the hierarchy as the parent AutomationElement does not point back to the owned form's AutomationElement. I've spent quite a bit of time today trying to gain access to the AutomationElement for the window without any success.
Ah, very interesting. I created a small test sample as you had, and I saw the same behaviour as you.
Then I tried to make another sample, which was similar to my application and have managed to replicate the behaviour I saw.
If I make an MDI parent form, which has an MDI child form which contains an UltraGrid and show the field chooser, then the field chooser doesn't show up on the automation elements tree (unless I manually find it using hover/focus mode).
See attached sample. Click on one of the grid cells to show the field chooser.
The UltraGridColumnChooser is displayed on a separate form that is owned by the same form as the grid itself. In my test sample, Inspect.exe shows the AutomationElement for the 'Field Chooser" as the first child of the main form. Hopefully this will help you gain access to the column chooser.
Let me know if you have further questions.