C# WinForms(或 Win32 API)中是否有一种方法可以在不添加控件作为父控件且不扩展窗口边框的情况下偏移窗体的子控件的原点 {0,0} 坐标?这就是我的意思:Win32 API 是否有类似 SetChildOffset() 函数的东西?我希望窗口边框保持不变。
1 回答
扬帆大鱼
TA贡献1799条经验 获得超9个赞
没有 API 可以做到这一点。而是使用这个:
private void SetChildOffset(int offset) {
//get all immediate children of form
var children = this.Controls.OfType<Control>();
foreach( Control child in children ) {
child.Location = new Point( child.Location.X + offset, child.Location.Y + offset );
}
}
- 1 回答
- 0 关注
- 431 浏览
添加回答
举报
0/150
提交
取消
