Hi,
I'm a newbie Ranorex user. I'm trying to read multiple rows from the grid/table object. So far I could only read info from one cell. I've checked other post and tried some of the recommended solution such as using FindDescendants in Foreach loop. However it didn't work. Below is my code:
public ValidateSort()
{
// Do not delete - a parameterless constructor is required!
var repo = Shared_ModulesRepository.Instance;
var mRNRow = repo.RETR_objects.SearchPatient.DataPanel.MRNRow0;
var textMaskBox1 = repo.RETR_objects.LayoutControl1.TextMaskBox1;
IList<Row> rows = mRNRow.FindDescendants<Row>();
foreach(Row row in rows){
System.Diagnostics.Debug.WriteLine(mRNRow.Text);
}
System.Diagnostics.Debug.WriteLine("This is a test output message from Patrick");
System.Diagnostics.Debug.WriteLine(mRNRow.Text);
textMaskBox1.Focus();
}
The attachment is the Ranorex snapshot file that contains the table object that I'm trying to access the info inside. Please advice.
Patrick
How to collect info from multiple cells in grid/table object
How to collect info from multiple cells in grid/table object
You do not have the required permissions to view the files attached to this post.
Re: How to collect info from multiple cells in grid/table object
Hi,
I use this method to read all the columns and rows inside a table to save the images it contains in every cell:
The for statement loops for every row in the table (in my case 2 rows), and the foreach loops for every column. The element called 'boton' is a exact copy from the one in the current cell.
Replace 'repo.SomeTableTag' with your element's xPath.
hope it helps.
regards,
Mateo.
I use this method to read all the columns and rows inside a table to save the images it contains in every cell:
Code: Select all
IList<Element> miTabla = repo.SomeTableTag.Element.Children;
for (int i = 0; i <= 1; i++)
{
foreach (Ranorex.Core.Element boton in miTabla[0].Children[i].Children)
{
miNewElement = boton.CaptureCompressedImage();
[...]
}
}
Replace 'repo.SomeTableTag' with your element's xPath.
hope it helps.
regards,
Mateo.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to collect info from multiple cells in grid/table object
Hi,
Thanks Mateo for your posting, I just wanted to describe an alternative way how this could also work.
I use the data from the snapshot for my small sample.
Markus
Thanks Mateo for your posting, I just wanted to describe an alternative way how this could also work.
I use the data from the snapshot for my small sample.
Container dataPanel = "/form[@controlname='RetrievePatientForm']/container/element/table/container[@accessiblename='Data Panel']"; // In oder to get the rows you could use the following code: IList<Row> rows = dataPanel.FindChildren<Row>(); foreach(Row row in rows){ // Values of the row Report.Info("Row Values: "+row.Element.GetAttributeValue("AccessibleValue")); // Getting the cells of the current row IList<Cell> cells = row.FindChildren<Cell>(); foreach(Cell cell in cells){ // Text of the current Cell Report.Info("Cell Text: "+cell.Text); } }Regards,
Markus