You can do something like this
int gridCubeWidth = 16, gridCubeHeight = 16;
cube.Position.X = Math.Floorround(cube.Position.X / gridCubeWidth) * gridCubeWidth;
cube.Position.Y = Math.Floorround(cube.Position.Y / gridCubeHeight) * gridCubeHeight;
This basically rounds the X and Y positions to the nearest multiple of the cube dimensions. Then scales it by the cube dimensions to get the uniform position.