📄 form2.vb
字号:
Public Class Form2
Inherits System.Windows.Forms.Form
Dim Row As DataRowCollection
Dim TheRow As Int16
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Button7 As System.Windows.Forms.Button
Friend WithEvents Button6 As System.Windows.Forms.Button
Friend WithEvents Button5 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Button7 = New System.Windows.Forms.Button
Me.Button6 = New System.Windows.Forms.Button
Me.Button5 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(40, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "ID编号"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(112, 21)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(40, 72)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(32, 16)
Me.Label2.TabIndex = 2
Me.Label2.Text = "姓名"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(96, 64)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(112, 21)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(40, 128)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(32, 16)
Me.Label3.TabIndex = 4
Me.Label3.Text = "单位"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(96, 120)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(224, 21)
Me.TextBox3.TabIndex = 5
Me.TextBox3.Text = ""
'
'Button7
'
Me.Button7.Location = New System.Drawing.Point(288, 200)
Me.Button7.Name = "Button7"
Me.Button7.Size = New System.Drawing.Size(56, 32)
Me.Button7.TabIndex = 52
Me.Button7.Text = "修改"
'
'Button6
'
Me.Button6.Location = New System.Drawing.Point(416, 200)
Me.Button6.Name = "Button6"
Me.Button6.Size = New System.Drawing.Size(56, 32)
Me.Button6.TabIndex = 51
Me.Button6.Text = "返回"
'
'Button5
'
Me.Button5.Location = New System.Drawing.Point(344, 200)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(72, 32)
Me.Button5.TabIndex = 50
Me.Button5.Text = "修改确认"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(224, 200)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(64, 32)
Me.Button4.TabIndex = 49
Me.Button4.Text = "下一个"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(160, 200)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(64, 32)
Me.Button3.TabIndex = 48
Me.Button3.Text = "上一个"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(96, 200)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 32)
Me.Button2.TabIndex = 47
Me.Button2.Text = "尾记录"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 200)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(72, 32)
Me.Button1.TabIndex = 46
Me.Button1.Text = "首记录"
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(498, 264)
Me.ControlBox = False
Me.Controls.Add(Me.Button7)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Name = "Form2"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "读者库管理"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ds = New DataSet '数据表集合
da = New OleDb.OleDbDataAdapter("SELECT * FROM borrower", ConAccess) '引用方式
da.Fill(ds, "borrower")
TextBox1.DataBindings.Add("Text", ds.Tables("borrower"), "ID")
TextBox2.DataBindings.Add("Text", ds.Tables("borrower"), "xm")
TextBox3.DataBindings.Add("Text", ds.Tables("borrower"), "jys")
Row = ds.Tables("borrower").Rows
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
TheRow = 0
TextBox1.Text = Row(TheRow).Item(0).ToString
TextBox2.Text = Row(TheRow).Item(1).ToString
TextBox3.Text = Row(TheRow).Item(2).ToString
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
TheRow = Row.Count - 1
TextBox1.Text = Row(TheRow).Item(0).ToString
TextBox2.Text = Row(TheRow).Item(1).ToString
TextBox3.Text = Row(TheRow).Item(2).ToString
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
If TheRow > 0 Then
TheRow = TheRow - 1
TextBox1.Text = Row(TheRow).Item(0).ToString
TextBox2.Text = Row(TheRow).Item(1).ToString
TextBox3.Text = Row(TheRow).Item(2).ToString
Else
MessageBox.Show("已经到了文件首部!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
If TheRow < Row.Count - 1 Then
TheRow = TheRow + 1
TextBox1.Text = Row(TheRow).Item(0).ToString
TextBox2.Text = Row(TheRow).Item(1).ToString
TextBox3.Text = Row(TheRow).Item(2).ToString
Else
MessageBox.Show("已经到了文件尾部!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
Private Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
Row(TheRow).BeginEdit()
End Sub
Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
Row(TheRow).EndEdit()
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -