您可以在表单上拥有相对控件大小吗? [英] Can you have a relative control size on a Form?

查看:63
本文介绍了您可以在表单上拥有相对控件大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个DataGrid,它在对话框上显示数据

应用程序。调整对话框大小时,数据网格保持相同的形状,我们需要数据网格保持相对形状比较

当用户调整大小时对话框的其余部分它。关于如何使用
的任何想法都可以做到这一点?


谢谢!

Hi everyone, I have a DataGrid that displays data on a dialog
application. When the dialog is resized, the datagrid keeps the same
shape, We would need the datagrid to keep a relative shape compared to
the rest of the dialog when the user resizes it. Any ideas on how to
do this?

Thanks!

推荐答案

设置锚点 DataGrid的属性。您可能希望

从顶部,左侧切换它toTop,Left,Bottom,RIght。


锚属性表示控件边缘与b
绑定的形式的哪一边。因此,默认情况下,数据网格的顶部始终是距离表单顶部相同的距离,并且左边缘保持与

的距离。左边缘。你总是想要底部&右边缘

坚持各自的形式边缘。

Set the "Anchor" property of the DataGrid. You must likely want to
switch it from "Top, Left" to "Top, Left, Bottom, RIght".

The anchor property says which edge of the form the edge of the control
are tied to. So, by default, the top of the datagrid is always the
same distance from the top of the form, and the left edge mantains it''s
distance from the left edge. You alway want the bottom & right edges
to stick to their respective form edges.


这在.NET 1.1中无法做到...至少,并非没有做很多

乱搞Resize事件中的自定义代码。警告:在事件中获得

时机可能很难看:我记得很容易

最终无限大小调整和/或闪烁等等。


在.NET 2.0中,我不明白为什么你不能创建一个自定义布局管理器

了解比例(如果没有''''已经......如果有的话,我还没有b $ b。我不熟悉.NET 2.0

分割面板控件是如何工作的,但它似乎是

的自然候选者,允许在保留相对控件大小的同时调整大小。 br />
This cannot be done in .NET 1.1... at least, not without doing a lot of
messing around with custom code in Resize events. Warning: getting the
timing right inside the events can be ugly: as I recall it''s easy to
end up with infinite resizing and/or flickering, etc.

In .NET 2.0 I don''t see why you can''t create a custom layout manager
that understands proportions (if there isn''t one already... I haven''t
run across it if there is one). I''m not familiar with how the .NET 2.0
split panel control works, but it would seem a natural candidate for
allowing resize while retaining relative control sizes.


er.um ...以及使用Anchor属性的确切错误

(在.Net 1.1中可用) & 2.0)

er.um...and exactly what''s wrong with using the Anchor property
(available in .Net 1.1 & 2.0)


这篇关于您可以在表单上拥有相对控件大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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