Control editmode from code