Can focus on SplitContainer be avoided?

WinForm SplitContainer gets focus when it is dragged or clicked, but Splitter does not. A side effect of this is that dragging the SplitContainer panel launches Leave / Validate on other controls, and I need to avoid this.

I have already tried setting TabStop and CausesValidation to False, but without success.

Is there a way to stop SplitContainer from working? (it doesn't matter, I can still use the old Splitter, but I'm losing some good VS properties ...)

+3
source share
3 answers

Remove the SplitContainer control and manually replace it with the Panel and Splitter controls. A little more effort, but a much cleaner result.

+2
source

Try using this code:

//This code will move the focus from the splitContainer to TreeView shortly after moved.
private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e) {
    if(this.splitContainer1.CanFocus) {
       this.splitContainer1.ActiveControl = this.treeView1;
    }
}
+1
source

Filini,

, , - . , .

private void Button_Leave(object sender, EventArgs e)
{
    if(SplitContainer.ContainsFocus)
        return;
}

, , , , SplitContainer .

, .

0

Source: https://habr.com/ru/post/1713342/


All Articles