如何自动调整datagridview以删除空白区域 [英] How to autosize datagridview to delete blank gray areas

查看:318
本文介绍了如何自动调整datagridview以删除空白区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我的程序是一个vb.net Windows窗体应用程序,我正在寻找一种简单的方法来自动调整我的datagridview以摆脱空白的灰色背景区域。我知道一个简单的方法是更改​​背景颜色以匹配表单,但是我希望调整datagridview的大小以永远不显示空白的灰色区域。有一个简单的方法吗?非常感谢您提供的任何帮助或建议。谢谢!

解决方案

DGV没有AutoSize属性,也不支持调整其内容的大小。



我能想到的唯一方法就是枚举colums,获取它们的宽度并将它们相加,然后将DGV的宽度设置为,再加上一点额外的滚动条和边框

Hello my program is a vb.net windows forms application and I'm looking for a simple way to autosize my datagridview to get rid of the blank gray background areas. I know that an easy way to do this is to change the background color to match the form, however I'm looking to resize the datagridview to never show the blank gray area. Is there a simple way to do this? I greatly appreciate any help or suggestions you may offer. Thanks!

解决方案

The DGV doesn't have the AutoSize property and doesn't support resizing itself to its content.

The only way I can think of to do this would be to enumerate the colums, get their widths and add them up, then set the width of the DGV to that, plus a little extra probably for a scrollbar and borders.


这篇关于如何自动调整datagridview以删除空白区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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