Yes, while racing, riding, and even just trying to get off my bike. I've also had my leg/s seize while driving after a hard ride/race.
I find that using higher gears with lower cadence helps me deal with cramps. For me the rapid muscle firing of high cadences causes me to actually seize. By pedaling much slower, in a higher gear, I can keep going for a while. I am rarely able to stay with others if I'm in a cramping phase.
As for preventing cramps I can't offer advice. I do best if I'm fit and reasonably hydrated. Electrolyte drinks seem to cause me to cramp, even when I'm super fit. I stick with sugar and water type drinks (either soda or plain water).