• 主页
  • 即使单击子元素,也将焦点放在父元素中

即使单击子元素,也将焦点放在父元素中

我有一个包含标签和PictureBox的UserControl (让我们称它为"PresentationCell")。在另一个使用此PresentationCell的控件中,我添加了一个事件

presentationCell.GotFocus += OnFocus;

private void OnFocus(object sender, EventArgs e)
{
    if (sender is PresentationCell current)
        current.BackColor = Color.Azure;
}

如果我单击/焦点在PresentationCell中的标签或PictureBox上,则不会触发此操作。

PresentationCell中只有一些东西处于焦点时,我如何才能让它触发呢?

转载请注明出处:http://www.jubohx.com/article/20230518/1172003.html