Dock和Anchor有什么区别 [英] What is the difference between Dock and Anchor

查看:93
本文介绍了Dock和Anchor有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体,在
中有很多控件(列表框,组框,组合框,文本框,列表框等)。我需要调整
的大小,并在表单的大小更改
时自动排列控件。我需要知道Dock和Anchor之间的区别,以实现
Docking和
Anchoring之间的实际区别是什么?

I have a windows form which have a lot of controls in that(Listbox,Groupbox,Combobox,TextBox,ListBox etc). I need to resize and arrange the controls automatically whenever the form's size gets changed. I need to know the difference between Dock and Anchor to implement this. What is the actual difference between Docking and Anchoring?

推荐答案

The Anchor and Dock表单的属性是两个单独的属性。

The Anchor and Dock properties of a form are two separate properties.

锚点是指控件相对于表单边缘的位置。例如,固定在表单左边缘的文本框将与调整表单大小时保持相同位置。

Anchor refers to the position a control has relative to the edges of the form. A textbox, for example, that is anchored to the left edge of a form will stay in the same position as the form is resized.

停放是指您希望控件在表单上占用多少空间。如果将控件停靠在窗体的左侧,它将自动将其拉伸到窗体的高度,但其宽度将保持不变。

Docking refers to how much space you want the control to take up on the form. If you dock a control to the left of the form, it will stretch itself to the height of the form, but its width will stay the same.

示例可以帮助您了解更多信息。

This EXAMPLE can help you understand a bit more.

这篇关于Dock和Anchor有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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