>>35410018No, it's when you catch them. Due to programming fuckery, the Pokemon you catch and the Pokemon you have in your party/PC after are different with gender being the only thing locked.
Fun fact, the Zangoose in GoD can change gender since you fight/see it in battle twice prior to catching it.
Speaking of, I swear I heard about a glitch with that Zangoose where it's lost forever if you fail to snag it instead of Miror B getting it but I can't find a source. Does anyone know where it came from?