SplitContainer.Panel1 选择更改 SplitContainer.Panel2 选择

发布于 2024-08-02 22:18:12 字数 481 浏览 3 评论 0原文

SplitContainer 控件的 MSDN 文档说:

使用 SplitContainer 控件,您可以创建复杂的用户界面; 通常,在一个面板中进行选择 确定显示哪些对象 另一个面板。

所以,我有一个水平分割的 SplitContainer,具有顶部和底部面板。 我想做的是——当 Panel1(顶部)内的控件获得焦点时,我需要 Panel2(底部)内的控件获得焦点。然后焦点必须再次返回到Panel1 中的控件。

问题是,Panel2 中的控件在 CanFocus 上返回 false。我知道对于某些类型的控件来说,这种情况可能会发生,并且控件的每个祖先都必须具有焦点才能接收焦点。我也尝试过,但没有效果。 CanFocus 仍然返回 false。

有没有其他解决方案?有没有人尝试过这个。我想做的与 Outlook 所做的基本上相同。当您在收件箱中选择一条消息时。消息正文显示在底部面板中。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅笑轻吟梦一曲 2024-08-09 22:18:12

您所描述的内容并不模仿 Outlook。如果我在 Outlook 的邮件列表中选择一封邮件,焦点仍保留在邮件列表中。是的,消息正文确实出现在下面,但焦点没有移动。

不应该有任何事情阻止您更改任一面板中显示的控件或内容。您不必转移焦点即可实现这一目标。

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.

随波逐流 2024-08-09 22:18:12

您真的需要将焦点设置到 Panel2 吗?

我猜您的 Panel2 包含类似 RichTextBox 对象的内容,为简单起见,称为 RTB1。

假设有人在 Panel1 中选择了某些内容。为简单起见,假设您有一个名为 LV1 的 ListView 控件。

然后,在 LV1.SelectedIndexChanged 事件中,读取该事件并将数据填充到 RTB1。

你真的不需要给Panel2焦点,除非我遗漏了一些东西。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文