How to detect the color of a specific row in a DataGridView control?

Scenario:

I am building an automation that gets some orders from an API and then opens a specific system (built within C# WinForms) and creates a new order with filling its data into some textboxes controls and then clicks the create button to add the order and the order appears on a DataGridView control under the textboxes controls. The DataGridView displays the row with the created order data which refers to the success of the creation of the order. Then the order after created it is synced automatically into another system (WinForms application) for further processing. The normal user can know that the created order is synced into the second system by the row color which changes into a green color. If the order in some how didn’t synced after the creation then the row color is still white and no changes for the row color which means that the user needs to sync the order manually into the second system.

Question:

How can I detect the color of the specific row in the DataGridView control in order to automate the process of checking whether the order is synced into the second system?

The color is in Excel right?

You can use:
https://docs.uipath.com/activities/other/latest/productivity/excel-get-cell-color

I hope the below topic will helps you.

Can we assume a Desktop Application that is not Excel?

It is not in an excel. the scenario is about desktop aaplications and datagridview control in winforms c#

I think this is related with excel, but in my scenario I am talking about detecting colors of rows in a desktop application contains a dataGridView control.

Yes, we can assume a Desktop Application that is not Excel. In fact, the question specifically states that the application is a C# WinForms application.

I am using UiPath Studio to automate a process in a C# WinForms application. I need to detect the color of a specific row in a DataGridView control in order to check whether the order is synced into another system.

My question is, how can I detect the color of a specific row in a DataGridView control in a C# WinForms application?

Perfect as we assumed this from

  • Check all Selectors / try also F4 Change UiFramework if any attribute (to left panel within UiExplorer) if any hint to the color is offered

  • As a last resort we can check a pixel from the field on its color

1 Like
1 Like

I end with this solution to detect the row color in any DataGridView control for desktop applications:

Steps:

  1. Extract the data in the DataGridView control into a DataTable.
  2. Search for the specific value (e.g., order ID) in the DataTable to get the DataRow variable.
  3. Get the index of the DataRow variable.
  4. Use the Take Screenshot activity to take a screenshot of any cell in the first row of the DataGridView control.
  5. Choose the UI framework for the “Take Screenshot” as Active Accessibility.
  6. Edit its selector and replace the static value of the row with the index of the row that you got from the DataTable.
  7. Output the image into a variable.
  8. Create a Bitmap variable and pass the image into the Bitmap variable.
  9. Use the Invoke Code activity use the following code to get the color value of the captured screenshot for the row:

var color = myBitmap.GetPixel(1, 1);

@postwick @ppr I appriaciate your help thank you

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.