Selecting an item from tr which has 12 rows.

Class library usage, coding and language questions.
sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Selecting an item from tr which has 12 rows.

Post by sham526 » Wed Jul 07, 2010 7:24 am

i am facing an problem in selecting an particular row with row number but i was failed to perform because there is no event like Item(VB) in c#.

My code is like

Ranorex.TableTag tagtable = new Ranorex.TableTag (repo.Home.Loss.tblSelect);
Ranorex.TBodyTag tb=tagtable.FindSingle<Ranorex.TBodyTag>("./tbody");
System.Collections.Generic.IList<TrTag> trSel = tb.Find<Ranorex.TrTag>("./tr");
MessageBox.Show(trSel.Count.ToString());
System.Collections.Generic.IList<TdTag> tdSel = tb.Find<Ranorex.TdTag>("./tr/td");
MessageBox.Show(tdSel.Count.ToString());

i can get the count but i cant select an item.

totally tr has 12 rows and td has 140 columns and i want to access the 10row How to get the element in c# ?



Vb code which is working correctly:


Dim progTbl As Ranorex.TableTag = repo.Home.Loss.tblSelect
Dim tb As Ranorex.TBodyTag = progTbl.FindSingle(Of Ranorex.TBodyTag)("./tbody")
Dim tr As System.Collections.Generic.List(Of TrTag)= tb.Find(Of Ranorex.TrTag)("./tr")
Dim td As System.Collections.Generic.List(Of TdTag)= tb.Find(Of Ranorex.TdTag)("./tr/td")
msgbox(td.Count)
msgbox(td.Item(14).InnerText.ToString)


this is working fine but in c# it dosent have an item property which was highlited in red color

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Selecting an item from tr which has 12 rows.

Post by Support Team » Wed Jul 07, 2010 9:19 am

Hi,

The indexers in C# and Vb .Net are different. Please take a look to following documentation
http://msdn.microsoft.com/en-us/library/2549tw02.aspx

Here is a little example for indexers in C# and VB .Net
'VB .Net
msgbox(td.Item(14).InnerText)
//C#
MessageBox.Show(td[14].InnerText);
Regards,
Peter
Ranorex Support Team

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: Selecting an item from tr which has 12 rows.

Post by sham526 » Wed Jul 07, 2010 9:29 am

thanks problem solved.