False row-numbering

Class library usage, coding and language questions.
fp_philipp
Posts: 7
Joined: Fri Apr 10, 2009 10:43 am

False row-numbering

Post by fp_philipp » Wed Apr 15, 2009 10:04 am

Hi Ranorex-Supportteam!

First of all i want to pay you a complimant for this great product ;)

I'm working with Ranorex 2.0.1 libraries and i maybe found a bug or misbehaviour.
My Infragistics Ultragrid contains 4 rows, if i want to access different cells in different rows, like this:

Code: Select all

ErfassenGUI.Ultratable.Rows[0].Cells[2].Click();
ErfassenGUI.Ultratable.Rows[1].Cells[3].Click();
ErfassenGUI.Ultratable.Rows[2].Cells[3].Click();
ErfassenGUI.Ultratable.Rows[3].Cells[4].Click();
it doesn't work, because the cell of the first row is clicked twice and the last cell won't get clicked at all.
I tested around changing cellnumbers and order and got a solution:

Code: Select all

ErfassenGUI.Ultratable.Rows[0].Cells[2].Click();
ErfassenGUI.Ultratable.Rows[2].Cells[3].Click();
ErfassenGUI.Ultratable.Rows[3].Cells[3].Click();
ErfassenGUI.Ultratable.Rows[4].Cells[4].Click();
But the strange thing is:

Code: Select all

ErfassenGUI.Ultratable.Rows[1].Cells[2].Click();
ErfassenGUI.Ultratable.Rows[2].Cells[3].Click();
ErfassenGUI.Ultratable.Rows[3].Cells[3].Click();
ErfassenGUI.Ultratable.Rows[4].Cells[4].Click();
doesn't work... because there the second row get clicked twice...

it seems like in the first statement the numbering of the rows start with 0 and after that it starts with 1...

is this a known issue?

greets
philipp

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu Apr 16, 2009 1:29 pm

I don't think that is a bug in Ranorex. My guess is that clicking on the first row inserts another row at the beginning of the table, probably an editable row or something like that. From then on the first row isn't the first row any more, but the second one :-)

The Table.Rows property returns a simple list of Row instances and list indices always start with zero. This list is constructed every time you access the Rows property by searching for Row instances inside the table. I.e. the Rows property will always give you the currently available rows in the table. You can, however, try to store the initially available rows into a variable and then enumerate those:

Code: Select all

IList<Row> rows = ErfassenGUI.Ultratable.Rows;
rows[0].Cell[2].Click();
rows[1].Cell[3].Click();
...
// or you simply enumerate all the rows
foreach (Row row in rows)
    rows.Cell[0].Click(();
Regards,
Alex
Ranorex Support Team

fp_philipp
Posts: 7
Joined: Fri Apr 10, 2009 10:43 am

Post by fp_philipp » Fri Apr 17, 2009 8:03 am

Thanks for the help!

Storing the rows in an new instance works well :D

I'm so sorry that i didn't consider the option that it could be a problem of the table :oops:

Keep on that good work and support! :wink:
philipp