📄 frmset.vb
字号:
Public Class frmSet
Inherits System.Windows.Forms.Form
#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 Cancel As System.Windows.Forms.Button
Friend WithEvents Sure As System.Windows.Forms.Button
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Cancel = New System.Windows.Forms.Button
Me.Sure = New System.Windows.Forms.Button
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'Cancel
'
Me.Cancel.Location = New System.Drawing.Point(128, 80)
Me.Cancel.Name = "Cancel"
Me.Cancel.Size = New System.Drawing.Size(88, 24)
Me.Cancel.TabIndex = 5
Me.Cancel.Text = "取消"
'
'Sure
'
Me.Sure.Location = New System.Drawing.Point(16, 80)
Me.Sure.Name = "Sure"
Me.Sure.Size = New System.Drawing.Size(88, 24)
Me.Sure.TabIndex = 4
Me.Sure.Text = "确定"
'
'ComboBox1
'
Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox1.Items.AddRange(New Object() {"(请选择教室)"})
Me.ComboBox1.Location = New System.Drawing.Point(16, 32)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(200, 20)
Me.ComboBox1.TabIndex = 3
'
'frmSet
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(232, 134)
Me.Controls.Add(Me.Cancel)
Me.Controls.Add(Me.Sure)
Me.Controls.Add(Me.ComboBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmSet"
Me.Text = "设置"
Me.ResumeLayout(False)
End Sub
#End Region
Dim sqlstr As String = "SELECT DISTINCT cRoom FROM course"
Dim mycon As New SqlConnection(Control.constr)
Dim mycom As New SqlCommand(sqlstr, mycon)
Dim myread As SqlDataReader
Dim dsql As String
Private Sub frmSet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
mycon.Open()
myread = mycom.ExecuteReader
While myread.Read()
ComboBox1.Items.Add(myread(0))
End While
myread.Close()
ComboBox1.SelectedIndex = 0
Catch ex As Exception
MsgBox("数据库连接失败!" & ex.ToString, , "错误信息")
mycon.Close()
Me.Close()
Exit Sub
End Try
End Sub
Private Sub Sure_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sure.Click
If (ComboBox1.SelectedIndex = 0) Then
MsgBox("请选择教室!", , "提示")
Exit Sub
End If
Me.Hide()
Dim fCard As New frmCard
fCard.StartPosition = Windows.Forms.FormStartPosition.CenterScreen
fCard.ShowDialog()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
mycon.Close()
Me.Close()
End
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Control.choice = ComboBox1.Text
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -