Search code examples
c#datagridviewui-automationmicrosoft-ui-automation

How to provide GridPattern to custom control


We have a custom control which derives from DataGridView.

Now I want to write an automated test, which clicks on a row of this DataGridView. I'm using Microsoft UI Automation for this.

Unfortunately, the GridPattern is not available, because it's a custom control...

How can I make this custom control testable with Microsoft UI Automation?

Do I have to implement IGridProvider? And if yes, how do I have to do this?

Thanks for your help


Solution

  • According to this https://msdn.microsoft.com/en-us/library/ms744822(v=vs.110).aspx DataGridView will only be supported through microsoft active accessibility. So it looks like you would need to implement IGridProvider and IGridItemProvider.

    These articals talk about implementing custom properties and providers in general

    Part 1 UIA-CustomPatterns

    Part 2 UIA-CustomPatterns

    Part 3 UIA-CustomPatterns

    Part 4 UIA-CustomPatterns

    Then you would want to implement IGridProvder and then implement IGridItemProvider for the items in the grid.