This project is read-only.

Number of rows read from datagrid is incomplete

Aug 18, 2012 at 9:11 AM

I have been using White for about three months now. I am happy about the outcome so far. But today I faced this problem with reading data from a datagrid. The Rows property of the datagrid shows only 11 rows while actually the datagrid has more than a thousand row. Did anyone encounter such a problem?


Thanks in advance. 

Aug 18, 2012 at 12:57 PM

Found the following thread:

Looks promising to me. I will give it a try.

Aug 18, 2012 at 3:29 PM
Edited Aug 20, 2012 at 10:02 AM

I tried to integrated the code as follows

        private static List<GroupTelephone> GetGroupTelephones(OneTeamWindow oneTeamWindow)
            var rowsCollection = new List<ListViewRow>();
            List<ListViewCells> allRows = new List<ListViewCells>();

            Helper.FindAllRows(rowsCollection, allRows, oneTeamWindow.DgGroupTelephones);

            return allRows.Select(row => new GroupTelephone
                                                            TelephoneSelectionBox = row[0].GetControl(),
                                                            TelepphoneNumber =row[1].GetValue(),
                                                            SubscriberNumber = row[2].GetValue(),
                                                            SubscriberName = row[3].GetValue(),
                                                            JoinDate = row[4].GetValue(),
                                                            ConnectionState = row[5].GetValue(),
                                                            ShortCode = row[6].GetValue(),
                                                            RentalWithProfile = row[7].GetValue(),
                                                            Feedback = row[8].GetValue()                    
public static void FindAllRows(List<ListViewRow> rows, List<ListViewCells> allRows, ListView resultGrid)
            bool added = false;
 foreach (ListViewRow row in resultGrid.Rows)
                if (!rows.Contains(row))
                    added = true;
            if (added)
                FindAllRows(rows,allRows, resultGrid);
        public static IEnumerable<ListViewCells> GetGridCells(ListView resultGrid)
            return resultGrid.Rows.Select(row => new BricksCollection<AutomationElement>(row.AutomationElement.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, "DataGridCell")))).Select(coll => new ListViewCells(coll, resultGrid.ActionListener, resultGrid.Header)).ToList();

However, an unhandled exception is thrown:
The CLR has been unable to transition from COM context 0x70ae90 to COM context 0x70b0b8 for 60 seconds. 
The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a 
very long running operation without pumping Windows messages. This situation generally has a negative performance impact 
and may even lead to the application becoming non responsive or memory usage accumulating continually over time. 
To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives 
(such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.