本文整理汇总了VB.NET中System.Windows.Forms.DataGridViewRowCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DataGridViewRowCollection.AddRange方法的具体用法?VB.NET DataGridViewRowCollection.AddRange怎么用?VB.NET DataGridViewRowCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了DataGridViewRowCollection.AddRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: AddRows
' Workaround for bug that prevents DataGridViewRowCollection.AddRange
' from working when the row for new records is selected.
Private Sub AddRows(ByVal ParamArray rows As DataGridViewRow())
InsertRows(dataGridView1.RowCount - 1, rows)
End Sub
' Workaround for bug that prevents DataGridViewRowCollection.InsertRange
' from working when any rows before the insertion index are selected.
Private Sub InsertRows(ByVal index As Integer, _
ByVal ParamArray rows As DataGridViewRow())
Dim selectedIndexes As New System.Collections.Generic.List(Of Integer)
For Each row As DataGridViewRow In dataGridView1.SelectedRows
If row.Index >= index Then
selectedIndexes.Add(row.Index)
row.Selected = False
End If
Next row
dataGridView1.Rows.InsertRange(index, rows)
For Each selectedIndex As Integer In selectedIndexes
dataGridView1.Rows(selectedIndex).Selected = True
Next selectedIndex
End Sub