Set Connection from Object Explorer

If you need to switch connection of the current SQL Editor window to any database displayed in Object Explorer - right-click it in Object Explorer and choose   Set as active connection:

Script Object feature in SSMS