Clicking Windows.forms.datagrid

May 19, 2008 at 9:38 PM
I am trying to make a selection in a system.windows.forms.datagrid.  I am attempting it using the following code:

Panel searchView = AppData.mainWindow.Get<Panel>("agtSearchResultList");

 

AutomationElement targetAE = UIHelper.getAutomationElementViaDescendantChain(searchView.AutomationElement, new string[1] { "listDataGrid" }, new bool[1] { true });

 

 

ListView grid = new ListView(targetAE, nal);

 
grid.Rows[0].DoubleClick();


get.AutomationElementViaDescendantChain is a routine that finds the AutomationElement by traversing the chain.  I have verified that targetAE is assigned to the correct grid AutomationElement. 

I originally was using Table instead of ListView, until a saw a post suggesting using the ListView, but it is acting the same either way.  It just get stuck on the DoubleClick command (or any other command using the grid object, such as grid.Rows.Count).  If I pause the app, I see the following data for the grid object:

?grid

 

 

{Core.UIItems.ListView}

base {Core.UIItems.UIItem}: {Core.UIItems.ListView}

Core.UIItems.ListViewItems.SuggestionList.Items: Cannot evaluate expression because a native frame is on top of the call stack.

handler: null

Header: Cannot evaluate expression because a native frame is on top of the call stack.

listViewFactory: {Core.UIItems.ListViewItems.ListViewFactory}

Rows: Cannot evaluate expression because a native frame is on top of the call stack.

SelectedRows: Cannot evaluate expression because a native frame is on top of the call stack.



Any suggestions how I can get this to work?

Thanks!

 

Coordinator
May 20, 2008 at 7:21 AM
What you are doing is correct.
Can you provide me some sample app where I can reproduce this.