I have a dockable window with a single listview control on it. Selecting an item in the view will build a layer and add it to the map. At the point of the layer being added to the map, I need to set focus to the map. However, focus remains on the listview.

My issue is exactly the same as the following thread: How to set focus on ArcMap map window using arcobjects and c#.net. I have followed the suggested answer in that thread of using an IntPtr, but it doesn't set focus to the map.

The following is the line of code that I am using in a public method after the layer has been added to the TOC and map:


As an fyi, I have also declared the following at the top of the class:

// Sets the keyboard focus to the specified window.
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr SetFocus(IntPtr hWnd);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.