- Public Class Form1
- Public ds As New DataSet()
- Enum Products
- ProductID
- ProductName
- ProductQTY
- End Enum
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- initDB()
- Me.BindingSource1.DataSource = ds
- Me.BindingSource1.DataMember = ds.Tables(0).TableName
- Me.BindingNavigator1.BindingSource = Me.BindingSource1
- Me.DataGridView1.DataSource = Me.BindingSource1
- End Sub
- Public Sub initDB()
- Dim dt As New DataTable
- dt.Columns.Add(Products.ProductID.ToString())
- dt.Columns.Add(Products.ProductName.ToString())
- dt.Columns.Add(Products.ProductQTY.ToString())
- Dim i As Integer = 0
- For i = 0 To 1000 Step 1
- Dim dr As DataRow = dt.NewRow
- dr(Products.ProductID) = "ID:" + i.ToString()
- dr(Products.ProductName) = "Name:" + i.ToString()
- dr(Products.ProductQTY) = "QTY:" + i.ToString()
- dt.Rows.Add(dr)
- Next
- ds.Tables.Add(dt)
- End Sub
- End Class
BindingSource BindingNavigator
最新推荐文章于 2019-07-25 18:17:00 发布