Getting midi lined up to bars

MIDI is something I usually add at the end but on this occasion I played a riff in at the start and now I want to change the grid to match the freely played in midi, I know how to do this with audio and I would have thought midi would be even easier but I’m a bit stumped even after trawling through the manual.

If you are using the TimeWarp tool, then the principle is the same. Do so from inside either the Key (or Drum) Editor, or in the Project window with the track’s In-Place Editor open.