Sometimes when the Ranorex code (or recording) clicks on a cell in a table (grid) to enter a value, the value gets entered in a different cell than what we clicked on. The cells has tooltips that appears when you hover over them, and we suspect that the position of hovering tooltip is sometimes confusing things and causes Ranorex to click where the tooltip is showing instead of on the cell it was told to go to.

Either way, whatever the reason is, it seems that just clicking on a cell is not enough to make sure that is the cell that will be active to receive data entry. For example, my recording would do something like this:

To make sure we enter the value into the correct cell, it seems that we need to use something else than Click(). The idea is to somehow get focus on the cell in question, and then press F2 to put it in Edit mode, and only then enter the value.

This only seems to work if the focus is currently in that grid. So, if we worked with a cell in a different grid right BEFORE the above code is executed, it enters the value in that cell. Which is not the cell the code is telling it to go to.

Or, the Focus and Select statement can be swapped too, it seems to work the same in either order. Which makes me wonder if I can trust this code to always behave as expected.

Is this really the best way achieve this? I'm wondering why Select does not work on its own without Focus. If you specify which cell it should Select already (as part of the repo selection), why do you need Focus to direct it to the right Grid as well?

I'm wondering why Select does not work on its own without Focus. If you specify which cell it should Select already (as part of the repo selection), why do you need Focus to direct it to the right Grid as well?

Just because an item is selected it doesn't mean that it has the focus and vice versa.
Maybe the easiest way to solve your problem is to set the value of the cell directly. This can be done as follows:

For some tests it should work to use SetAttributeValue. However, for other tests, it needs to be more "user entry" oriented. I think SetAttributeValue is moving away from being "user entry" oriented.

For example, verifying that you can only enter numeric values, and that you get an appropriate error message if you don't, should rather be more "user input" driven. Would a "Focus", "Select", and F2 to put it in edit mode be the best way for this type of situation?

If your program is well designed result should be the same, regardless of whether you perform a PressKeys or a SetValueAction. Maybe have a look at the action listener and the methods running in the background of your program to find out if there are some differences.

I would say SetValueAction is the more elegant way.
Nevertheless you can handle your problem with "Focus", "Select", and F2.