DataGridView row loop

Hi, can you help me about this case please.

I’d like to Sum Column1 and Column2 and then write the result to Column3. But the question is, how can I do it for all 6 rows in a loop until the last row and then stop.

It’s not an excel table, it’s VB .NET DataGridView .

image

Selector for the first row of the cell 1:

wnd ctrlname=‘dgvList’
ctrl name=‘DataGridView’ role=‘table’
ctrl name=‘Row 0’ role=‘row’
ctrl name=‘ColumnName’ role=‘cell’

Thanks in advance.

Use Do while loop
Put your object which contains the selectors inside Do while loop body
assign Counter = Counter+1 inside Do while loop body
Then change the Row 0 with the Counter Variable
in condition put Counter < 6

go through below video
https://academy.uipath.com/learn/course/10/play/348/lesson-sap-video

1 Like

One option would be to use the Extract Structured Data or Data Scrape Wizard. This would give you a data table, then you can use a For each on it, and you wouldn’t need a counter in this case. Then, I will normally look at the available attributes on one of the cells to see if there is a tableRow and tableColumn attribute, because this would allow you to replace with the index from the For each loop for row number.

‘Row 0’ might be the row number if tableRow doesn’t exist. You would need to replace the number with the index from the For each loop.
"<wnd ctrlname=‘dgvList’ /><ctrl name=‘DataGridView’ role=‘table’ /><ctrl name=‘Row "+rowIndex.ToString+"’ role=‘row’ /><ctrl name=‘ColumnName’ role=‘cell’ />"

The newer versions of Studio may handle variables in selectors differently, but my example is editing the selector in the Expression editor where it is surrounded by quotations.

Find children is also an option, but more complex I feel.

Regards.

1 Like

@Jenni_K If Data scrapping is possible then definitely you should use it.

I could’t open the video. It says: You don’t have permission to access this page.

Any chance to watch it from an alternative link?

<ctrl name=‘Row “+rowIndex.ToString+”’ role=‘row’ /> this notation didn’t work. You sure about the syntax?

Sign up in academy.uipath.com
Uipath has very good tutorial videos

I’ve already signed up, I think it’s maybe because it’s a further course.

image

Can you use UiExplorer and show an image of what the selector looks like for a few cells in the first row and a few cells in the second row. Also, show an image of some of your code and how you have implemented this. That would help identify what the issue is. The syntax is correct, however, the selector or how you used it could be wrong maybe.

One thing that will help you is output your selector string where you have added the rowIndex on it using either a Write Line or Message Box. Then, you can compare it with what UiExplorer shows that the selector should be. That way, you know if your selector string is correct or not.

Regards.