form1.vb

来自「Visual Basic .NET程序设计教程源代码」· VB 代码 · 共 859 行 · 第 1/4 页

VB
859
字号
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim headstr As String = "该通讯录"
    Public Sub showposition()
        Dim icnt As Integer
        Dim ipos As Integer
        icnt = Me.BindingContext(DataSet11, "detail").Count
        If icnt = 0 Then
            '如果总共为0条
            lblposition.Text = "没有任何记录"
        Else
            '如果不是0条记录,那么设置lblposition的Text属性显示相关信息
            ipos = Me.BindingContext(DataSet11, "detail").Position + 1
            lblposition.Text = headstr & "共" & icnt.ToString & "条记录,当前为第" & ipos.ToString & "条,id为"
        End If
    End Sub
    Private Sub setall(ByVal tf As Boolean)
        txtname.ReadOnly = tf
        txtbirth.ReadOnly = tf
        txtemail.ReadOnly = tf
        txtphone.ReadOnly = tf
        txtmobile.ReadOnly = tf
        txtbp.ReadOnly = tf
        txtaddress.ReadOnly = tf
        txtpc.ReadOnly = tf
        txtdemo.ReadOnly = tf
        btnfirst.Enabled = tf
        btnprevious.Enabled = tf
        btnnext.Enabled = tf
        btnlast.Enabled = tf
        btndel.Enabled = tf
        btnsearch.Enabled = tf
        btnall.Enabled = tf
    End Sub
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    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

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents btnfirst As System.Windows.Forms.Button
    Friend WithEvents btnprevious As System.Windows.Forms.Button
    Friend WithEvents btnnext As System.Windows.Forms.Button
    Friend WithEvents btnlast As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents txtmobile As System.Windows.Forms.TextBox
    Friend WithEvents txtbirth As System.Windows.Forms.TextBox
    Friend WithEvents txtphone As System.Windows.Forms.TextBox
    Friend WithEvents txtname As System.Windows.Forms.TextBox
    Friend WithEvents txtaddress As System.Windows.Forms.TextBox
    Friend WithEvents txtbp As System.Windows.Forms.TextBox
    Friend WithEvents txtemail As System.Windows.Forms.TextBox
    Friend WithEvents txtpc As System.Windows.Forms.TextBox
    Friend WithEvents btnadd As System.Windows.Forms.Button
    Friend WithEvents btnall As System.Windows.Forms.Button
    Friend WithEvents btnsearch As System.Windows.Forms.Button
    Friend WithEvents btnmodify As System.Windows.Forms.Button
    Friend WithEvents txtsname As System.Windows.Forms.TextBox
    Friend WithEvents txtid As System.Windows.Forms.TextBox
    Friend WithEvents txtdemo As System.Windows.Forms.TextBox
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents btnexit As System.Windows.Forms.Button
    Friend WithEvents lblposition As System.Windows.Forms.Label
    Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
    Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
    Friend WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter
    Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents Addressdetail11 As ex1201.addressdetail1
    Friend WithEvents brower As System.Windows.Forms.TabControl
    Friend WithEvents DataSet11 As ex1201.DataSet1
    Friend WithEvents btndel As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnfirst = New System.Windows.Forms.Button
        Me.btnprevious = New System.Windows.Forms.Button
        Me.btnnext = New System.Windows.Forms.Button
        Me.btnlast = New System.Windows.Forms.Button
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.btndel = New System.Windows.Forms.Button
        Me.btnmodify = New System.Windows.Forms.Button
        Me.btnsearch = New System.Windows.Forms.Button
        Me.btnall = New System.Windows.Forms.Button
        Me.btnadd = New System.Windows.Forms.Button
        Me.txtsname = New System.Windows.Forms.TextBox
        Me.txtmobile = New System.Windows.Forms.TextBox
        Me.Addressdetail11 = New ex1201.addressdetail1
        Me.txtbirth = New System.Windows.Forms.TextBox
        Me.txtphone = New System.Windows.Forms.TextBox
        Me.txtname = New System.Windows.Forms.TextBox
        Me.txtaddress = New System.Windows.Forms.TextBox
        Me.txtbp = New System.Windows.Forms.TextBox
        Me.txtemail = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.txtpc = New System.Windows.Forms.TextBox
        Me.txtid = New System.Windows.Forms.TextBox
        Me.lblposition = New System.Windows.Forms.Label
        Me.txtdemo = New System.Windows.Forms.TextBox
        Me.Label9 = New System.Windows.Forms.Label
        Me.btnexit = New System.Windows.Forms.Button
        Me.brower = New System.Windows.Forms.TabControl
        Me.TabPage1 = New System.Windows.Forms.TabPage
        Me.TabPage2 = New System.Windows.Forms.TabPage
        Me.TabPage3 = New System.Windows.Forms.TabPage
        Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
        Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDataAdapter
        Me.OleDbDeleteCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCommand
        Me.DataSet11 = New ex1201.DataSet1
        Me.GroupBox1.SuspendLayout()
        CType(Me.Addressdetail11, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.brower.SuspendLayout()
        CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'btnfirst
        '
        Me.btnfirst.Location = New System.Drawing.Point(8, 264)
        Me.btnfirst.Name = "btnfirst"
        Me.btnfirst.Size = New System.Drawing.Size(64, 23)
        Me.btnfirst.TabIndex = 0
        Me.btnfirst.Text = "最前一个"
        '
        'btnprevious
        '
        Me.btnprevious.Location = New System.Drawing.Point(88, 264)
        Me.btnprevious.Name = "btnprevious"
        Me.btnprevious.Size = New System.Drawing.Size(56, 23)
        Me.btnprevious.TabIndex = 1
        Me.btnprevious.Text = "上一个"
        '
        'btnnext
        '
        Me.btnnext.Location = New System.Drawing.Point(144, 264)
        Me.btnnext.Name = "btnnext"
        Me.btnnext.Size = New System.Drawing.Size(56, 23)
        Me.btnnext.TabIndex = 2
        Me.btnnext.Text = "下一个"
        '
        'btnlast
        '
        Me.btnlast.Location = New System.Drawing.Point(216, 264)
        Me.btnlast.Name = "btnlast"
        Me.btnlast.Size = New System.Drawing.Size(64, 23)
        Me.btnlast.TabIndex = 3
        Me.btnlast.Text = "最后一个"
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.btndel)
        Me.GroupBox1.Controls.Add(Me.btnmodify)
        Me.GroupBox1.Controls.Add(Me.btnsearch)
        Me.GroupBox1.Controls.Add(Me.btnall)
        Me.GroupBox1.Controls.Add(Me.btnadd)
        Me.GroupBox1.Controls.Add(Me.txtsname)
        Me.GroupBox1.Location = New System.Drawing.Point(296, 152)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(200, 120)
        Me.GroupBox1.TabIndex = 4
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "数据操作"
        '
        'btndel
        '
        Me.btndel.Location = New System.Drawing.Point(16, 88)
        Me.btndel.Name = "btndel"
        Me.btndel.Size = New System.Drawing.Size(56, 23)
        Me.btndel.TabIndex = 4
        Me.btndel.Text = "删除"
        '
        'btnmodify
        '
        Me.btnmodify.Location = New System.Drawing.Point(16, 56)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?