⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmcustomers.vb

📁 vb.net MCP课程的英文讲义,70-310课程,值得一读
💻 VB
字号:
Public Class frmCustomers
    Inherits System.Windows.Forms.Form
    Private objCargo As New Component.Cargo()

#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
    Private WithEvents lstCustomers As System.Windows.Forms.ListBox
    Private WithEvents txtAddress As System.Windows.Forms.TextBox
    Private WithEvents txtID As System.Windows.Forms.TextBox
    Private WithEvents txtCompany As System.Windows.Forms.TextBox
    Private WithEvents txtEmail As System.Windows.Forms.TextBox
    Private WithEvents lblEmail As System.Windows.Forms.Label
    Private WithEvents lblAddress As System.Windows.Forms.Label
    Private WithEvents lblCompany As System.Windows.Forms.Label
    Private WithEvents lblID As System.Windows.Forms.Label

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    '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.
    <System.Diagnostics.DebuggerStepThroughAttribute()> Private Sub InitializeComponent()
        Me.lblEmail = New System.Windows.Forms.Label()
        Me.lblID = New System.Windows.Forms.Label()
        Me.txtAddress = New System.Windows.Forms.TextBox()
        Me.lblCompany = New System.Windows.Forms.Label()
        Me.lstCustomers = New System.Windows.Forms.ListBox()
        Me.txtID = New System.Windows.Forms.TextBox()
        Me.lblAddress = New System.Windows.Forms.Label()
        Me.txtEmail = New System.Windows.Forms.TextBox()
        Me.txtCompany = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'lblEmail
        '
        Me.lblEmail.Location = New System.Drawing.Point(208, 112)
        Me.lblEmail.Name = "lblEmail"
        Me.lblEmail.TabIndex = 1
        Me.lblEmail.Text = "Email"
        '
        'lblID
        '
        Me.lblID.Location = New System.Drawing.Point(208, 8)
        Me.lblID.Name = "lblID"
        Me.lblID.TabIndex = 1
        Me.lblID.Text = "ID"
        '
        'txtAddress
        '
        Me.txtAddress.Location = New System.Drawing.Point(208, 200)
        Me.txtAddress.Multiline = True
        Me.txtAddress.Name = "txtAddress"
        Me.txtAddress.Size = New System.Drawing.Size(200, 32)
        Me.txtAddress.TabIndex = 2
        Me.txtAddress.Text = ""
        '
        'lblCompany
        '
        Me.lblCompany.Location = New System.Drawing.Point(208, 64)
        Me.lblCompany.Name = "lblCompany"
        Me.lblCompany.TabIndex = 1
        Me.lblCompany.Text = "Company"
        '
        'lstCustomers
        '
        Me.lstCustomers.Location = New System.Drawing.Point(8, 8)
        Me.lstCustomers.Name = "lstCustomers"
        Me.lstCustomers.Size = New System.Drawing.Size(192, 225)
        Me.lstCustomers.TabIndex = 0
        '
        'txtID
        '
        Me.txtID.Location = New System.Drawing.Point(208, 32)
        Me.txtID.Name = "txtID"
        Me.txtID.Size = New System.Drawing.Size(200, 20)
        Me.txtID.TabIndex = 2
        Me.txtID.Text = ""
        '
        'lblAddress
        '
        Me.lblAddress.Location = New System.Drawing.Point(208, 176)
        Me.lblAddress.Name = "lblAddress"
        Me.lblAddress.TabIndex = 1
        Me.lblAddress.Text = "Address"
        '
        'txtEmail
        '
        Me.txtEmail.Location = New System.Drawing.Point(208, 136)
        Me.txtEmail.Multiline = True
        Me.txtEmail.Name = "txtEmail"
        Me.txtEmail.Size = New System.Drawing.Size(200, 32)
        Me.txtEmail.TabIndex = 2
        Me.txtEmail.Text = ""
        '
        'txtCompany
        '
        Me.txtCompany.Location = New System.Drawing.Point(208, 80)
        Me.txtCompany.Name = "txtCompany"
        Me.txtCompany.Size = New System.Drawing.Size(200, 20)
        Me.txtCompany.TabIndex = 2
        Me.txtCompany.Text = ""
        '
        'frmCustomers
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(416, 245)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtCompany, Me.lblID, Me.lblCompany, Me.lblAddress, Me.lblEmail, Me.txtEmail, Me.txtID, Me.txtAddress, Me.lstCustomers})
        Me.Name = "frmCustomers"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

   
   
    Private Sub frmCustomers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        objCargo.GetCustomers()
        Dim CurRows() As DataRow, CurRow As DataRow
        CurRows = objCargo.CustList.Select
        For Each CurRow In CurRows
            lstCustomers().Items.Add(CurRow("FirstName").ToString & _
            " " & CurRow("LastName").ToString)
        Next
        lstCustomers().SelectedIndex = 0
    End Sub

    Private Sub lstCustomers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstCustomers.SelectedIndexChanged
        Dim RowNum As Integer = lstCustomers().SelectedIndex
        Dim CurRow As DataRow = objCargo.CustList.Rows(RowNum)
        txtID().Text = CurRow("CustomerID").ToString
        txtCompany().Text = CurRow("CompanyName").ToString
        txtEmail().Text = CurRow("Email").ToString
        txtAddress().Text = CurRow("Address").ToString
    End Sub
End Class

⌨️ 快捷键说明

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