DataGridView自动调整高度 [英] DataGridView auto size height

查看:951
本文介绍了DataGridView自动调整高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经使用了一个C#winform中的datagridview,以便使用所有的分配的空间?我已经使用了 gv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; 以宽度自动调整gridview的大小。现在我想使用全高可用,所以没有背景是可见的。



当我一直到网格视图中的最后一个记录仍然是一个灰色的背景可见。



我的网格视图是正确的,并且调整大小以及表单的工作也很好。我只是想摆脱不必要的可见背景。



提示V4Vendetta给了我一些窍门。

解决方案

您可以使用Dock,或者更精确的控制使用Anchor属性。通过将锚点设置为左,右,上,下,控件将与窗口缩放。通过将Anchor设置为Right,控件将以右边界移动。通过将锚点设置为顶部和底部,控件将垂直缩放,但具有固定的宽度。只是试验


How can I size an datagridview in a C# winform to make use of all his allocated space?

I have allready used gv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; to auto size the gridview in width. Now I want to make use of the full height available so no background is visible.

When I'am schrolling all the way down to the last record in the gridview there is still an gray background visible.

My gridview is anchored right and resizing along with the form works also fine. I just wanted to get rid of unnecessary visible background.

The tip V4Vendetta gave me did the trick.

解决方案

You can use Dock, or for more precise control use the Anchor property. By setting Anchor to Left, Right, Top, Bottom the control will scale with the window. By setting Anchor to Right the control will move with the right border. By setting Anchor to Top and Bottom the control will scale vertically, but have a fixed width. Just experiment

这篇关于DataGridView自动调整高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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