错误;指数超出范围.必须为非负数且小于

本文关键字:小于 指数 范围 错误 | 更新日期: 2023-09-27 18:35:56

foreach (TcpConnectionInformation info in tcpConnections)
{
    dataGridView1.Rows[0].Cells[1].Value =info.LocalEndPoint.Address.ToString();
}

我正在使用此代码将值放入 GridView 中,但发生了此错误。

IndexOutOfRangeException - Index 超出范围。必须为非负数且小于 集合。

参数名称:索引

谢谢问候

错误;指数超出范围.必须为非负数且小于

index 参数引用行 [0] 或单元格 [1]

请检查 dataGridView1 中是否至少有一行,并且第一行至少有 2 个单元格。

相关文章: