Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
foreach (TcpConnectionInformation info in tcpConnections) { dataGridView1.Rows[0].Cells[1].Value =info.LocalEndPoint.Address.ToString(); }
我正在使用此代码将值放入 gridview 但发生此错误。
IndexOutOfRangeException - 索引超出范围。必须是非负数且小于集合的大小。
参数名称:索引
感谢和问候
index参数指的是 Rows[0] 或 Cells[1 ]
请检查 dataGridView1 中是否至少有一行,并且第一行至少有 2 个单元格。