テキストボックスボックスでクリックされたデータグリッド値を表示しようとしています。しかし今、この例外を取得イム:datagrid_cellclick
イベントのテキストボックスにデータグリッド値を表示する際にエラーが発生しました
Object reference not set to an instance of an object.
私のコードはこれです...
if (e.RowIndex >= 0)
{
DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
comboBox2.Text = row.Cells[4].Value.ToString();
txtID.Text = row.Cells[0].Value.ToString();
txtName.Text = row.Cells[1].Value.ToString();
txtAddress.Text = row.Cells[2].Value.ToString();
//txtPhone.Text = row.Cells[3].Value.ToString();
txtBalance.Text = row.Cells[5].Value.ToString();
}
は(ヌル)空のセルのいずれかのですか? –
いいえ、私はフィールドの長いテキストデータ型にint値を挿入します。これが原因なの? –