When I tab from another control to a combo box it shows the box with a dotted line around the text, but when I set the control to be active programmatically, it doesn\'t show th
This is by design of the operating system, prevents clutter on the screen when a user is not using the keyboard. Here is a thorough explanation of the reasons. And here is an explanation of how the mechanism works.
You can send a WM_UPDATEUISTATE to change the state of a window (and its child windows as per the documentation).
ComboBox1.Perform(WM_UPDATEUISTATE, MakeWParam(UIS_CLEAR, UISF_HIDEFOCUS), 0);
Above will update the UI state of the combobox as if keyboard cues are required.
You don't have to send the message at focus switch time, you can send it at form creation for instance. You can also choose to send the message to the parent form, for all the controls to behave consistently, and can include UISF_HIDEACCEL
in the high-word of WParam to also show accelerator characters underlined.
Note that users already can choose to display keyboard indicators at all times system-wise. In Windows 7, the setting is at "Control Panel", "Ease of Access Center", "Make the keyboard easier to use", "Make it easier to use keyboard shortcuts", "Underline keyboard shortcuts and access keys".