views:

91

answers:

1

I have a WinForm with 2 ListView controls. The first listview is on the left hand side and presents the list of categories, the second is on the right hand side, and presents items within a category. Think of it like the classic explorer-type UI, but specialized: the hierarchy is just one level deep.

If I have a listviewItem highlighted on the LHS, and click an arrow key, the form automatically handles it. I don't have a KeyPress event handler (or a handler for KeyDown/KeyUp), but I learned that TreeView and ListView have builtin function for handling arrow keys as navigation inputs.

The problem is, the form handles it in a non-intuitive way. Focus changes to listview2, and then subsequent arrow key inputs navigate within the items of listview2. What I would like is for focus to remain in the listview it was in, originally.

How do I make sure that when the listview that has focus, alone, handles the up/down arrows?

+2  A: 

You presumably are doing something on the treeview's NodeSelected event, that moves focus to the listview. If you can post the code in your question, maybe we can work out what it is?

Neil Barnwell
(sheepish) Ah, yes, it was in the SelectedIndexChanged event. In that event, I update the other listview, and that was causing the focus to shift.
Cheeso