c# - datagridview c#的参数超出范围异常
问题描述
在 DataGridView 上显示数据期间出现错误我认为这是相关的 -1 问题,但我该如何处理我无法实现的这 3 个条件。当数据计数为 3 时没有问题。
当数据计数为 2 或 1 时,程序会给出参数超出范围异常等错误。
...
DataTable abc = new DataTable();
sda.Fill(abc);
DataGridView.DataSource = abc;
if (Convert.ToString(DataGridView.Rows[0].Cells["xyz"].Value) != null && Convert.ToString(DataGridView.Rows[1].Cells["xyz"].Value) != null && Convert.ToString(DataGridView.Rows[2].Cells["xyz"].Value) != null)
{
textbox1.Text = Convert.ToString(DataGridView.Rows[0].Cells["xyz"].Value);
textbox2.Text = Convert.ToString(DataGridView.Rows[1].Cells["xyz"].Value);
textbox3.Text = Convert.ToString(DataGridView.Rows[2].Cells["xyz"].Value);
...
解决方案
推荐阅读
- r - 如何从 R 中的 aov 摘要中进行子集化?
- kentico - Kentico:与 XML 数据源相关的问题,403 错误
- android-studio - 为什么 Android Studio 在运行 Flutter 应用时找不到 x86 模拟器?
- javascript - 在没有 Jquery 的情况下单击将类添加到子元素
- jquery - jQuery ReferenceError:找不到变量:事件
- angular - 在不使用 *ngIf 的情况下单击另一个 div 时显示一个 div
- html - 我们可以在一个输入中加入 2 个 HTML 模式吗?
- node.js - 构建后电子Linux应用程序不显示图标
- angular - Angular 2 routerLink 参数和查询参数
- oracle - APEX 办公室打印