C#datagridview行和列的大小为内容

编程入门 行业动态 更新时间:2024-10-17 13:29:52
本文介绍了C#datagridview行和列的大小为内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好 我在一个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行和列的大小为内容

本文发布于:2023-11-10 16:20:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575870.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小   内容   datagridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!