Keeping an object that follows a mouse snapping to a grid is very simple, and you'll find lost of examples of it on the forums.
But here's how to do it, along with an explanation of the logic behind the maths.
To snap an object to the mouse for a 32x32 grid (for example), you update the objects position like this:
(Pseudo Code)
ObjectXPosition = Int(ObjectXPosition/32)*32
ObjectYPosition = Int(ObjectYPosition/32)*32
...changing the 32s to whatever grid size you want.
Now, it looks like it's just dividing by 32 and then multiplying by 32, which would seem to get you back to the same figure, but the important part is the INT, and the brackets.
By dividing it's position by 32 and then turning it into an INT, you effectively cut off anything that's not an exact division of 32.
Then you multiply by the second 32, which multiplies the new Integer value, and you have your exact, on-grid position.
For instance, Int(35/32)*32=32 [the value 35 becomes 32, as would values like 49 or 57]
Int(73/32)*32=64 [the value 73 becomes 64, as would any value from 65 to 95]
Krush.