设置控制父属性和使用Controls.Add()之间的区别?
更具体地说,是这些陈述
ownerControl.GroupBox1.Controls.Remove(childControl); ownerControl.Controls.Add(childControl);
相当于
childControl.Parent = ownerControl;
看看reflection器,它看起来像Parent
只调用Add
(当新的父元素为非null时)。 Controls.Add
处理从旧父母那里取走它。 实际上,以下是function相同的(当ownerControl
不为null时):
ownerControl.Controls.Add(childControl); // note no Remove etc
和:
childControl.Parent = ownerControl;
反直觉,但快速测试表明它有效。
上述就是C#学习教程:设置控制父属性和使用Controls.Add()之间的区别?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/955982.html