更新时间:2023-12-01 08:51:10
以下是向第一列使用 AutoIncrement 的数据表添加新行的示例:
Here is an example of adding a new row to a datatable that uses AutoIncrement on the first column:
定义表结构:
Dim dt As New DataTable
dt.Columns.Add("ID")
dt.Columns.Add("Name")
dt.Columns(0).AutoIncrement = True
添加新行:
Dim R As DataRow = dt.NewRow
R("Name") = txtName.Text
dt.Rows.Add(R)
DataGridView1.DataSource = dt