次のように、datagridview のソースとしてデータテーブルを作成しました。
Dim dt As New DataTable
dt.Clear()
DataGridView1.DataSource = dt
dt.Columns.Add("Customer")
dt.Columns.Add("Dtime")
dt.Columns.Add("Title")
dt.Columns.Add("EventID")
EventID は数値であり、新しいフォームに渡されて、どのレコードを開くかが伝えられます (そのビットは機能し、別のフォームで使用します)。
私が試してみました:
event = DataGridView1.SelectedRows(e.RowIndex).Cells(3).Value.ToString
event = Convert.ToInt32(DataGridView1.SelectedRows(0).Cells(3).Value.ToString)
event = Convert.ToInt32(DataGridView1.Item("EventID", DataGridView1.CurrentRow.Index).Value.ToString)
おそらく、このサイトや他のサイトで見つけた他の多くの方法がありますが、同じエラーが発生し続けます。
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
それは私を狂気に駆り立てています、私は何を間違っていますか?助けてください!