如何使用 WinForms 设置控件的 Z 顺序 [英] How to set Z-order of a Control using WinForms

查看:22
本文介绍了如何使用 WinForms 设置控件的 Z 顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个自定义 TextBox,它在获得焦点后会改变其边框样式.

I'm writing a custom TextBox that upon gaining focus changes its border style.

由于添加边框会导致控件与其相邻的控件重叠,因此我暂时将文本框放在对话框的前面(使用 textBox.BringToFront()).

As adding a border causes the control to overlap with those neighbouring it, I temporarily bring the text box to the front of the dialog (using textBox.BringToFront()).

但是,一旦编辑完成并且失去焦点,我想将控件发送回其在 Z 顺序中的原始位置.

However, once editing is complete and focus is lost, I would like to send the control back to its original position in the Z-order.

这可能吗(最好是简单的方式!)

Is this possible (preferably in a simple way!)

推荐答案

致电 GetChildIndexSetChildIndexControls 集合的方法.

这篇关于如何使用 WinForms 设置控件的 Z 顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆