gpt4 book ai didi

c# - 错误;索引超出范围。必须为非负且小于

转载 作者:可可西里 更新时间:2023-11-01 02:43:55 26 4
gpt4 key购买 nike

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

我正在使用此代码将值放入 gridview 但发生此错误。

IndexOutOfRangeException - Index was out of range. Must be non-negative and less than the size of the collection.

参数名称:索引

谢谢问候

最佳答案

index 参数指的是 Rows[0] 或 Cells[1]

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

关于c# - 错误;索引超出范围。必须为非负且小于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10814140/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com