DataGridView格式化,ColumnWidth问题 [英] DataGridView Formatting, ColumnWidth issue

查看:66
本文介绍了DataGridView格式化,ColumnWidth问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DataGridView来显示数据集.

I am using a DataGridView to display a DataSet.

DataSet单元格值具有各种小数位数,因此我将格式设置为几个有效数字

The DataSet cell values have various number of decimal places, so I set the format to a couple significant digits

Dim _Sender As DataGridView = TryCast(sender, DataGridView)
_Sender.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.Format = "F" & CInt(Decimal.ToString)

一切正常,但DataGridViewCellWidth似乎基于 实际 值,而不是 显示的 值.这导致列具有奇怪的宽度.我需要保留实际值,因为它用于其他用途. (单元格颜色与原始颜色不同时会发生变化 值)

That all works, but the DataGridViewCellWidth seems to be based on the actual value and not the displayed value. This is causing the columns to have strange widths. I need to maintain the actual value because it is used for other things. (cell color changes when different than original value)

关于如何将其更改为设置为AllCells的显示的AutoResizeColumns宽度的任何想法.

Any ideas on how to change it to the width of the displayed AutoResizeColumns set to AllCells.

谢谢

伙计,我在我头顶上方!

Man, Im in way over my head!!!

推荐答案

你好,

AllCells应该在设置列的格式之后工作,如果您经常更改格式,则可以在设置格式后尝试设置AutoSize.如果设置每一行而不是整列,则可能是问题所在.

AllCells should work after setting the format for the column, if you are changing the formatting often then you might try setting AutoSize after setting the format. If setting each row rather than the full column that might very well be the issue.



这篇关于DataGridView格式化,ColumnWidth问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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