This project is read-only.

Getting DateTimePicker instead of DataGridView

Mar 31, 2009 at 10:50 PM


We are trying to get the amount of rows in a DataGridView.  However, when using the following code to try to get the DataGridView we are getting a DateTimePicker object instead. We have also tried the SeachCriteria.ByText:

        Table ae = window.Get(SearchCriteria.ByAutomationId ("myGridString")) as Table;

                // editLinksWindow.Get(SearchCriteria.ByAutomationId ("myGridString")) Returns a DateTimePicker object

Then we tried the following to work around this with no luck:

1.       Cast the DataGridView as a ListView (same result as above).

2.       Using the AutomationElement, and then trying to find its children based on the caption each row has on screen (we have used other properties such as ClassName property with “DataGridRow” or “ListViewItem” as caption):

           AutomationElement ae = window.Get(SearchCriteria.ByAutomationId ("myGridString")).AutomationElement;

           AutomationElementCollection aeChildren = ae.FindAll (TreeScope.Descendants, new PropertyCondition (AutomationElement.NameProperty, "CellCaption"));


We are certain this is a DataGridView it is the object we can see it in the VisualStudio designer. The AutomationID and Text property are also correct.


Our Environment:

·         Winforms development

·         OS: Windows Vista, Windows XP.

·         White version

·         Visual Studio 2008 SP1.


We would appreciate if someone could provide some insight on this.