Winforms SplitterPanel,子重叠拆分的z-index [英] Winforms SplitterPanel, z-index of child overlap split
问题描述
我正在使用winforms中的SplitterPanel,在右侧,我需要一个自定义的下拉列表控件,该控件显示2列下拉列表。
I am working with a SplitterPanel in winforms where on the right hand side I want a custom dropdown list control which displays a 2 columns dropdown list.
问题是我希望有两列,所以我希望能够有一个比实际下拉列表更大的下拉列表区域,因此如果列表不适合拆分区域,则覆盖SplitterPanel。
The problem is that with there being two columns I want to be able to have a larger dropdown list area than the actual dropdown, and therefore overlap the SplitterPanel if the list doesn't fit in the split area.
我尝试使用 .BringToFront();
,但是这在SplitterPanel上不起作用,并且控件被隐藏。我来自网络背景,在该背景下我会使用z-index,但是我对winforms感到困惑。见下面的问题图片。
I have tried using .BringToFront();
, however this does not work on the SplitterPanel and the control is hidden. I come from a web background where I would have used z-index for this but I am stumped with winforms. See below image of my issue.
有人知道我该如何解决吗?
Does anyone know how I can resolve this?
推荐答案
TaW的上述回答帮助我解决了我的问题。对于我将参数移入方法中的情况,我做了一些修改,因为我已经将复选框控件设置为控件的属性,并通过向上移动父级直到到达顶部来获得目标。
TaW's answer above helped my solve my issue. I modified it slightly for my situation where I moved the parameters into the method as I already had my checkbox control set as a property of the control and got the target by looping up the parents until I got to the top.
private void moveCtlToTarget()
{
Control Target = Parent;
while (Target.Parent != null)
Target = Target.Parent;
Point pt = CheckBox.PointToScreen(Point.Empty);
CheckBox.Location = Target.PointToClient(pt);
CheckBox.Parent = Target;
CheckBox.BringToFront();
}
这篇关于Winforms SplitterPanel,子重叠拆分的z-index的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!