如何在不增加Gridview宽度的情况下显示Gridview Cell的完整内容 [英] how to show full content of Gridview Cell without the increasing of Gridview's width
本文介绍了如何在不增加Gridview宽度的情况下显示Gridview Cell的完整内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用这行代码在gridview的单元格中显示内容
I am using this line of code to show content in gridview's cell
dgvhadiths.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
这将在细胞中显示全部数据内容,但问题是;它已经增加了我的GRIDVIEW宽度。
我想根据我的winForm的大小来拟合gridview宽度加上我想要显示gridview的单元格的完整内容(不增加gridview宽度)。
THIS WILL SHOW FULL DATA CONTENT IN CELL BUT THE PROBLEM IS; IT HAVE INCREASED MY GRIDVIEW WIDTH TOO MUCH.
I WANT to fit gridview width according to the size of my winForm plus i want to show complete content of cell of gridview (without the increasing of gridview width).
推荐答案
您可以设置gridview的宽度,甚至是列宽本身。我想你想要在gridviw中包装文本。
DefaultCellStyle.WrapMode = DataGridViewTriState.True
AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
注意,如果您的数据中没有空格,则可能无法换行。如果是这种情况,您可能需要编写一个方法,每10-15个字符数量插入换行符,具体取决于列的大小。
You can set the width of the gridview, and even the column widths themselves. I would assume you want to wrap the text in the gridviw.
DefaultCellStyle.WrapMode = DataGridViewTriState.True
AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
Note, if your data has no spaces in it, it may not wrap. if that is the case, you may need to write a method to insert line breaks every 10-15 amount of characters, depending on the size of your column.
这篇关于如何在不增加Gridview宽度的情况下显示Gridview Cell的完整内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文