For Each selRow As DataGridViewRow In Me.DataGridView1.SelectedRows Dim rowView = TryCast(selRow.DataBoundItem, DataRowView) If rowView IsNot Nothing Then Dim row As DataRow = rowView.Row row("項目名") = 値 End If Next
'整列のため、SelectedRowsの格納順を取得する Dim SortList() As Integer ReDim SortList(Me.dgv_Data.SelectedRows.Count - 1) Dim idx As Integer = 0 For Each row As DataGridViewRow In Me.dgv_Data.SelectedRows SortList(idx) = row.Index idx += 1 Next Array.Sort(SortList) For Each sortno As Integer In SortList Me.dgv_Data.Item("品名", sortno).Value = inputText Next