简体   繁体   English

类型“ double”的值不能转换为“ System.Windows.Forms.DataGridViewCell”

[英]Value of type 'double' cannot be converted to 'System.Windows.Forms.DataGridViewCell

I want to show a list in DataGridView but the error says: 我想在DataGridView中显示一个列表,但错误显示:

Cannot implicitly convert type double to System.Windows.Forms.DataGridViewCell . 无法将double类型隐式转换为System.Windows.Forms.DataGridViewCell

What should I do? 我该怎么办?

for (int i = 0; i < nlength; i++)
{
    if (i % 2 == 0) data_result.Rows[i].Cells[0] =U[2 * i];
}

You have to set the value of the cell, not the cell itself. 您必须设置单元格的值,而不是单元格本身。 Look at this msdn article for more information 查看此msdn文章以获取更多信息

data_result.Rows[i].Cells[0].Value = U[2 * i];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不能将类型字符串隐式转换为 System.Windows.Forms.Datagridviewcell c# - cannot implicitly convert type string to System.Windows.Forms.Datagridviewcell c# 无法将DataGridViewCell的值转换为double - Cannot convert value of DataGridViewCell to double 如何修复此错误(System.Windows.Forms.DataGridViewCell.Value.get 返回 null。) - How Can Fixed This Erorr (System.Windows.Forms.DataGridViewCell.Value.get returned null. ) 无法将类型为“ System.Double”的对象转换为类型为“ System.Int32”的对象 - Object of type 'System.Double' cannot be converted to type 'System.Int32' 类型为“ System.Windows.Data.Binding”的对象不能转换为类型为“ System.Nullable`1 [System.Guid]” - Object of type 'System.Windows.Data.Binding' cannot be converted to type 'System.Nullable`1[System.Guid]' MSTest - DataTestMethod 抛出异常 System.ArgumentException:“System.Decimal”类型的对象无法转换为“System.Double”类型 - MSTest - DataTestMethod throws exception System.ArgumentException: Object of type 'System.Decimal' cannot be converted to type 'System.Double' 无法将类型 system.windows.forms.datagridtextboxcolumn 隐式转换为 system.windows.forms.datagridviewcolumn M&#39;alerter - cannot implicitly convert type system.windows.forms.datagridtextboxcolumn to system.windows.forms.datagridviewcolumn M'alerter 在LINQ dat source / gridview中使用文本框值作为参数:“String”类型的值无法转换为“Double”类型 - Using textbox value as parameter in LINQ dat source/gridview : A value of type 'String' cannot be converted to type 'Double' 无法将类型&#39;string&#39;隐式转换为&#39;System.Windows.Forms.TextBox&#39; - Cannot implicitly convert type 'string' to 'System.Windows.Forms.TextBox' 无法将类型&#39;System.Windows.Forms.Control&#39;隐式转换为&#39;object&#39; - Cannot implicitly convert type 'System.Windows.Forms.Control' to 'object'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM