//DataTable dt DataRow dr = dt.NewRow(); dt.Rows.InsertAt(dr, 0);
我遇到的问题,刚解决 Dim indexNumCount As Integer indexNumCount = gdv_detail_list.CurrentRow.Index + 1 Dim dt As DataTable = CType(Me.gdv_detail_list.DataSource, DataTable) Dim dr As DataRow = dt.NewRow() 'Set Value dr(0) = "" dr(1) = "" 'Add Row To DataTable 'dt.Rows.Add(dr) dt.Rows.InsertAt(dr, indexNumCount) '重新设置DataGridView的数据源 'Clear History DataSource Me.gdv_detail_list.DataSource = Nothing 'Set New Data Source Me.gdv_detail_list.DataSource = dt
//DataTable dt
DataRow dr = dt.NewRow();
dt.Rows.InsertAt(dr, 0);
Dim indexNumCount As Integer
indexNumCount = gdv_detail_list.CurrentRow.Index + 1 Dim dt As DataTable = CType(Me.gdv_detail_list.DataSource, DataTable)
Dim dr As DataRow = dt.NewRow()
'Set Value
dr(0) = ""
dr(1) = ""
'Add Row To DataTable
'dt.Rows.Add(dr)
dt.Rows.InsertAt(dr, indexNumCount) '重新设置DataGridView的数据源
'Clear History DataSource
Me.gdv_detail_list.DataSource = Nothing
'Set New Data Source
Me.gdv_detail_list.DataSource = dt