私のDataGridViewのSelectionChangedイベントのコードは次のとおりです。
Dim a as Integer
a = DataGridView1.CurrentRow.Index 'this certain line contains the error
TextBox1.Text = DataGridView1.Item(0,a).Value
'and all that jazz
コードは実行されますが、セルをクリックしてから列ヘッダーをクリックすると、エラーが表示されます。
このコード ブロックを CellContentClick という別のイベントに配置しようとしましたが、datagridview 内のセルをクリックしても、SelectionChanged に比べて応答が遅くなります。
これを修正する方法についてのアイデアはありますか?