在DataGridView C#中存储长值 [英] Storing long values in DataGridView C#

查看:60
本文介绍了在DataGridView C#中存储长值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DataGridView,它存储有关十六进制文件的信息。表行之一是块的原始十六进制数据。有时,它比DataGridViewTextBoxCell.MaxInputLength更长(〜90000),DataGridView不想让我将其存储在单元格中。我试图通过将其设置为int.MaxValue来避免出现这种情况,但它似乎不起作用... Cell的值根本不显示(但是debug显示,它在那里,已经成功存储在单元格中了。 )有人可以帮我吗?

I have a DataGridView, which stores info about a hex file. One of table rows is raw hex data of a chunk. Sometimes, it's longer(~90000) than DataGridViewTextBoxCell.MaxInputLength, and DataGridView don't want to let me store it in the cell. I am trying to avoid it by setting it to int.MaxValue, but it doesn't seem to work... The value of Cell simply don't display(But debug shows, that it's in there, successfully stored in the cell.) Can anyone help me?

我的代码:

if (s.Length >= ((DataGridViewTextBoxCell) this.datagridviewChunks.Rows[this.datagridviewChunks.Rows.Count - 1].Cells[1]).MaxInputLength)
{
    ((DataGridViewTextBoxCell) this.datagridviewChunks.Rows[this.datagridviewChunks.Rows.Count - 1].Cells[1]).MaxInputLength = int.MaxValue;
    ((DataGridViewTextBoxCell) this.datagridviewChunks.Rows[this.datagridviewChunks.Rows.Count - 1].Cells[1]).Value = s;
}


推荐答案

DataGridViewCell 似乎有最大 43679 个字符显示限制,这可能是由于渲染表单控件中的性能影响而导致的预期限制。该值存储在属性中,但未显示。

The DataGridViewCell seems to have a maximum 43679 characters display limit, possibly because of a intended limitation due to the performance impact in rendering form controls. The value is stored inside the property, but is not shown.

我还发现了与SQL Server Management Studio相关的问题 SSMS-无法粘贴网格模式下列中的字符超过了43679个字符,这可能是因为产品中使用了 DataGridView 类。

I also found a SQL Server Management Studio related issue SSMS - Can not paste more than 43679 characters from a column in Grid Mode, probably because the DataGridView class is being used in the product.

我建议您在表单上使用单独的 TextBox ,这样可以毫无问题地显示值。

I recommend you to use a separate TextBox instead on your form, which would show the value without any problem.

这篇关于在DataGridView C#中存储长值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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