You shouldn't forget that you're dealing with a computer here, iterating some 81 rectangles will only bore your CPU.
However since your grid is evenly spaced you don't actually need to iterate anything, but you can calculate within which cell the cursor is.
- Get the mouse position relative to the window
- Subtract the spacing around the grid (if there's any)
- Divide width and height by the width or height of a cell
- Round result down
Now you should end up with something like (0,0) for the top left cell, (0, 1) for the middle left cell, (2, 2) for the bottom right cell, etc.