公开课表格1 将Dim ds作为数据集 Dim dr As DataRow 昏暗的dt作为数据表
Private Sub btnaddnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddnew.Click
dr = dt.NewRow
dr(0) = txtcode.Text
dr(1) = CmbCategory.Text
dr(2) = txtname.Text
dr(3) = txtqty.Text
dr(4) = txtprice.Text
dt.Rows.Add(dr)
txtsubtotal.Text = Val(txtsubtotal.Text) + Val(txtqty.Text) * Val(txtprice.Text)
txtcode.Clear()
txtname.Clear()
txtqty.Clear()
txtprice.Clear()
txtcode.Focus()
txtdiscount.Text = 0
txttotal.Text = Val(txtsubtotal.Text) - Val(txtdiscount.Text)
End Sub
Private Sub txtcode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcode.KeyPress
If Asc(e.KeyChar) = 13 Then
txtname.Focus()
End If
End Sub
Private Sub txtcode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcode.TextChanged
End Sub
Private Sub txtname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtname.KeyPress
If Asc(e.KeyChar) = 13 Then
txtqty.Focus()
End If
End Sub
Private Sub txtname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtname.TextChanged
End Sub
Private Sub txtqty_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtqty.KeyPress
If Asc(e.KeyChar) = 13 Then
txtprice.Focus()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dt = New DataTable("Items")
dt.Columns.add("Code")
dt.Columns.Add("Category")
dt.Columns.Add("Name")
dt.Columns.add("Qty")
dt.Columns.add("Price")
ds = New DataSet()
ds.Tables.add(dt)
DataGridView1.DataMember = "Items"
DataGridView1.DataSource = ds
End Sub
Private Sub CmbCategory_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbCategory.SelectedIndexChanged
End Sub
结束班级