views:

299

answers:

2

The MSDN documentation for the SplitContainer controls says:

With the SplitContainer control, you can create complex user interfaces; often, a selection in one panel determines what objects are shown in the other panel.

So, I have a SplitContainer that is split horizontally having top and bottom panels. What I would like to do is -- when a control within Panel1 (on top) receives focus, I need a control within Panel2 (bottom) to be focused. And then the focus must go back to the control in Panel1 again.

The problem is, the control in Panel2 returns false on CanFocus. I understand that for some kind of controls this can happen, and that every ancestor of the control must have focus for it to receive focus. I tried that too, but to no avail. The CanFocus still returns false.

Is there any alternative solution to this? Has anyone tried this. What I am trying to do is essentially the same as what Outlook does. When you select a message in your Inbox. The message body shows up in the bottom panel.

A: 

What you're describing doesn't mimic Outlook. If I select a message in the message list in Outlook, focus remains with the message list. Yes, the message body does appear below, but the focus doesn't move.

There shouldn't be anything preventing you from changing either the control or the content that is displayed in either panel. You shouldn't have to move focus to accomplish that.

Adam Robinson
A: 

Do you really need to set focus to Panel2?

I'm guessing your Panel2 contains something like a RichTextBox object, say called RTB1 for simplicity.

Say someone selects something in Panel1. For simplicity, let's say you have a ListView control called LV1.

Then, on the LV1.SelectedIndexChanged event, read that event and fill your data to RTB1.

You don't really need to give Panel2 focus, unless there is something I'm missing.

jp2code