''DataGridViewのRowデータを消す
DataGridView1.Rows.Clear()
''mSQLpublishクラスから持ってきたDatatableを代入する
Dim dt As DataTable = mSQLpublish.CostomerInfomation(txtTel, txtName, txtAdress, txtCostomerCd, cmbItems,
mtxtFrom, mtxtTo, cmbStaff,
mtxtPost)
Dim pt As DataTable = mSQLpublish.purchasePoints
Dim ht As New Hashtable For i = 0 To pt.Rows.Count - 1 ht.Add(pt.Rows(i).Item("顧客コード").ToString, pt.Rows(i).Item("購入点数合計").ToString) Next ''Row数の分だけデータをDataGridViewに表示する For i = 0 To dt.Rows.Count - 1 DataGridView1.Rows.Add() DataGridView1.Rows(i).Cells(0).Value = dt.Rows(i).Item("名前") DataGridView1.Rows(i).Cells(1).Value = dt.Rows(i).Item("郵便番号").ToString.Substring(0, 3) & "-" & dt.Rows(i).Item("郵便番号").ToString.Substring(3) DataGridView1.Rows(i).Cells(2).Value = dt.Rows(i).Item("住所") DataGridView1.Rows(i).Cells(3).Value = dt.Rows(i).Item("電話番号") DataGridView1.Rows(i).Cells(4).Value = dt.Rows(i).Item("顧客コード") DataGridView1.Rows(i).Cells(5).Value = ht.Item(dt.Rows(i).Item("顧客コード").ToString If IsNothing(DataGridView1.Rows(i).Cells(5).Value) Then DataGridView1.Rows(i).Cells(5).Value = 0 End If Next DataGridView1.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight If 0 = DataGridView1.Rows.Count Then TextBox1.Text = messageTable.Item("MS008") Else TextBox1.Text = DataGridView1.Rows.Count & messageTable.Item("MS007") End If
上記のコードでDataGridView1.Rows(i).Cells(5).Valueのカラムをクリックしたときだけエラーになります。ご教示ください
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。