📄 customerform.vb
字号:
'TextBox2
'
Me.TextBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsCustomers1, "Customers.CompanyName"))
Me.TextBox2.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox2.Location = New System.Drawing.Point(10, 64)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(296, 22)
Me.TextBox2.TabIndex = 2
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsCustomers1, "Customers.ContactName"))
Me.TextBox3.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox3.Location = New System.Drawing.Point(10, 104)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(192, 22)
Me.TextBox3.TabIndex = 3
Me.TextBox3.Text = ""
'
'TextBox1
'
Me.TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsCustomers1, "Customers.CustomerID"))
Me.TextBox1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.Location = New System.Drawing.Point(10, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ReadOnly = True
Me.TextBox1.Size = New System.Drawing.Size(80, 22)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'TextBox4
'
Me.TextBox4.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsCustomers1, "Customers.ContactTitle"))
Me.TextBox4.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox4.Location = New System.Drawing.Point(10, 144)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(248, 22)
Me.TextBox4.TabIndex = 4
Me.TextBox4.Text = ""
'
'bttnFirst
'
Me.bttnFirst.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnFirst.Location = New System.Drawing.Point(10, 192)
Me.bttnFirst.Name = "bttnFirst"
Me.bttnFirst.Size = New System.Drawing.Size(40, 24)
Me.bttnFirst.TabIndex = 7
Me.bttnFirst.Text = "<<"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(340, 14)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 32)
Me.Button1.TabIndex = 5
Me.Button1.Text = "Load Table"
'
'bttnPrevious
'
Me.bttnPrevious.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnPrevious.Location = New System.Drawing.Point(58, 192)
Me.bttnPrevious.Name = "bttnPrevious"
Me.bttnPrevious.Size = New System.Drawing.Size(40, 24)
Me.bttnPrevious.TabIndex = 7
Me.bttnPrevious.Text = "<"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(470, 229)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblPosition, Me.bttnLast, Me.bttnNext, Me.bttnPrevious, Me.bttnFirst, Me.Label4, Me.Label3, Me.Label2, Me.Label1, Me.Button2, Me.Button1, Me.TextBox4, Me.TextBox3, Me.TextBox2, Me.TextBox1})
Me.Name = "Form1"
Me.Text = "Browsing the Customers Table"
CType(Me.DsCustomers1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DsCustomers1.Clear()
DACustomers.Fill(DsCustomers1, "Customers")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
DACustomers.Update(DsCustomers1)
Catch UpdateException As Exception
MsgBox(UpdateException.Message)
End Try
End Sub
Private Sub bttnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnPrevious.Click
Try
If Me.BindingContext(DsCustomers1, "Customers").Position > 0 Then
Me.BindingContext(DsCustomers1, "Customers").Position = (Me.BindingContext(DsCustomers1, "Customers").Position - 1)
PositionChanged()
End If
Catch dataException As Exception
MsgBox(dataException.Message)
Me.BindingContext(DsCustomers1, "Customers").CancelCurrentEdit()
End Try
End Sub
Sub PositionChanged()
lblPosition.Text = (((Me.BindingContext(DsCustomers1, "Customers").Position + 1).ToString + " / ") _
+ Me.BindingContext(DsCustomers1, "Customers").Count.ToString)
End Sub
Private Sub bttnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnNext.Click
Try
If Me.BindingContext(DsCustomers1, "Customers").Position < Me.BindingContext(DsCustomers1, "Customers").Count Then
Me.BindingContext(DsCustomers1, "Customers").Position = (Me.BindingContext(DsCustomers1, "Customers").Position + 1)
PositionChanged()
End If
Catch dataException As Exception
MsgBox(dataException.Message)
Me.BindingContext(DsCustomers1, "Customers").CancelCurrentEdit()
End Try
End Sub
Private Sub bttnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnFirst.Click
Try
Me.BindingContext(DsCustomers1, "Customers").Position = 0
PositionChanged()
Catch dataException As Exception
MsgBox(dataException.Message)
Me.BindingContext(DsCustomers1, "Customers").CancelCurrentEdit()
End Try
End Sub
Private Sub bttnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnLast.Click
Try
Me.BindingContext(DsCustomers1, "Customers").Position = Me.BindingContext(DsCustomers1, "Customers").Count - 1
PositionChanged()
Catch dataException As Exception
MsgBox(dataException.Message)
Me.BindingContext(DsCustomers1, "Customers").CancelCurrentEdit()
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -