Tel*_*nor 6 .net c# splitter splitcontainer winforms
是否有人可以建议替换WinForms SplitContainer的替代控件?我不喜欢SplitContainer在选中它和被拖动时如何显示奇怪的虚线条.我想让面板重新调整大小,因为用户拖动而不是鼠标向上,并且在拖动分割器时不显示任何虚线条.基本上就像在Vista浏览器中完成所有面板重新调整大小一样.
这是我所说的点缀的东西:

编写自己的拆分容器UserControl.您基本上只需将两个面板放到控件上(对于左侧和右侧面板),然后让它们之间的空间成为分割器.UserControl本身上的一个小MouseDown,MouseMove和MouseUp逻辑将让您轻松地左右移动"拆分器",两个面板将在分配器上的任何地方正确阻止,因此您的逻辑用于检查鼠标是否超过拆分器尽可能简单.
这可能是一项额外的工作,让控制按照您希望它在设计模式中的行为方式运行.
在看到你的问题之后我发现了这个,所以我想分享一下: SplitContainer FAQ
那里的第二个链接准确地说明了你需要做什么.
以下是链接永远消失的文本.
//1. Use the custom control defined in the SplitContainerNoFocus sample
//2. Insert the following code in your project, and attach these events to all of the SplitContainers that you don't want stealing focus.
// Temp variable to store a previously focused control
private Control focused = null;
private void splitContainer_MouseDown(object sender, MouseEventArgs e)
{
// Get the focused control before the splitter is focused
focused = getFocused(this.Controls);
}
private Control getFocused(Control.ControlCollection controls)
{
foreach (Control c in controls)
{
if (c.Focused)
{
// Return the focused control
return c;
}
else if (c.ContainsFocus)
{
// If the focus is contained inside a control's children
// return the child
return getFocused(c.Controls);
}
}
// No control on the form has focus
return null;
}
private void splitContainer_MouseUp(object sender, MouseEventArgs e)
{
// If a previous control had focus
if (focused != null)
{
// Return focus and clear the temp variable for
// garbage collection
focused.Focus();
focused = null;
}
}
Run Code Online (Sandbox Code Playgroud)