C#datagridview行和列的大小为内容 [英] C# datagridview rows and columns size to content
问题描述
大家好
我在一个winform的GroupBox中有一个DataGridView
此DataGridView的修订号为4行50列
DataGridView绑定到DataTable。
第1列是行的序号
我希望在调整winform大小时自动调整行的高度
我还希望在调整winform大小时自动调整列的宽度但是在这里我希望第1列只占用它需要的位置并且不是所有列的宽度都相同
非常感谢!
我尝试了什么:
我试过操纵AutoSizeRows / Columns属性
以下是可用选项的概述: Windows窗体DataGridView控件中的大小调整选项Microsoft Docs [ ^ ]
这是一篇相当过时的文章,可能会给你一些灵感:将数据网格列调整为内容 [ ^ ]
或者您可以尝试这样的自定义网格:
快速简单的DataGridView模拟 [ ^ ]
很多Ea sier to Use ListView [ ^ ]
Hi all
I have a DataGridView in a GroupBox in a winform
This DataGridView has a fix number of 4 rows and 50 columns
The DataGridView is bound to a DataTable.
The 1st column is the sequential number of the row
I want the height of the rows to be resized automatically as i resize the winform
I also want the width of the columns to resize automatically as i resize the winform but here i wish that the 1st column will take only the place it needs and not that the width of all the columns to be the same
Thanks very much!
What I have tried:
I have tried manipulation of the AutoSizeRows/Columns properties
Here is an overview of available options: Sizing Options in the Windows Forms DataGridView Control | Microsoft Docs[^]
Here is a rather dated article that might give you some inspiration: Resizing Data Grid Columns To Content[^]
Or you could try a custom grid like these:
A fast and simple DataGridView analogue[^]
A Much Easier to Use ListView[^]
这篇关于C#datagridview行和列的大小为内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!