winform中控件层叠问题
WPF中可以直接设置控件的层叠顺序,winform中怎么设置啊。 就是3个控件放在窗体同一个位置,直接通过动态改变3个控件的某个属性来控制3个控件哪个在最高层,哪个在第二第三层。是哪个属性啊? 不会是只能用 BringToFront和SendToBack吧,WPF那样多简单啊 winform 控件 层叠
[解决办法]
public void BringToFront()
{
if (this.parent != null)
{
this.parent.Controls.SetChildIndex(this, 0);
}
else if ((this.IsHandleCreated && this.GetTopLevel()) && SafeNativeMethods.IsWindowEnabled(new HandleRef(this.window, this.Handle)))
{
SafeNativeMethods.SetWindowPos(new HandleRef(this.window, this.Handle), NativeMethods.HWND_TOP, 0, 0, 0, 0, 3);
}
}