What you describe seems to be Patellar Tracking Disorder. (the Patellar is the knee cap to you and me) What happens with this is that when you stretch your leg or bend it, the knee cap will move to the side which can cause a great deal of pain. In most people is moves to the outside but for some it will move to the inside.
Causes of Patellar Tracking Disorder
It is usually a combination of things including:
- A problem with the formation of your knee from birth - flat knee cap maybe or knock knees.
- An out of balance or weak thigh muscle.
- Muscles and tendons with incorrect tension
- Cartilage damage in the Patellar.
Luckily most of the time this condition does not require surgery and is treated with physical therapy. You would need to see your doctor and be referred to a specialist to find out if surgery would be required but hopefully it will be easily treated.