📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
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 SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents MyDataSet1 As DataGrid.MyDataSet
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection()
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter()
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand()
Me.MyDataSet1 = New DataGrid.MyDataSet()
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
CType(Me.MyDataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "data source=ALLDOTNET;initial catalog=mydb;integrated security=SSPI;persist secur" & _
"ity info=False;workstation id=ALLDOTNET;packet size=4096"
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "学生成绩表", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID号", "ID号"), New System.Data.Common.DataColumnMapping("姓名", "姓名"), New System.Data.Common.DataColumnMapping("语文", "语文"), New System.Data.Common.DataColumnMapping("数学", "数学"), New System.Data.Common.DataColumnMapping("英语", "英语")})})
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT ID号, 姓名, 语文, 数学, 英语 FROM 学生成绩表"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'MyDataSet1
'
Me.MyDataSet1.DataSetName = "MyDataSet"
Me.MyDataSet1.Locale = New System.Globalization.CultureInfo("zh-CN")
Me.MyDataSet1.Namespace = "http://www.tempuri.org/MyDataSet.xsd"
'
'DataGrid1
'
Me.DataGrid1.AlternatingBackColor = System.Drawing.Color.DarkGray
Me.DataGrid1.BackColor = System.Drawing.Color.LightGray
Me.DataGrid1.BackgroundColor = System.Drawing.Color.Gainsboro
Me.DataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.DataGrid1.CaptionBackColor = System.Drawing.Color.DarkBlue
Me.DataGrid1.CaptionFont = New System.Drawing.Font("Courier New", 10.0!, System.Drawing.FontStyle.Bold)
Me.DataGrid1.CaptionForeColor = System.Drawing.Color.White
Me.DataGrid1.CaptionText = "学生成绩表"
Me.DataGrid1.DataMember = ""
Me.DataGrid1.DataSource = Me.MyDataSet1.学生成绩表
Me.DataGrid1.FlatMode = True
Me.DataGrid1.Font = New System.Drawing.Font("Courier New", 9.0!)
Me.DataGrid1.ForeColor = System.Drawing.Color.Black
Me.DataGrid1.GridLineColor = System.Drawing.Color.White
Me.DataGrid1.HeaderBackColor = System.Drawing.Color.DarkGray
Me.DataGrid1.HeaderFont = New System.Drawing.Font("Courier New", 10.0!, System.Drawing.FontStyle.Bold)
Me.DataGrid1.HeaderForeColor = System.Drawing.Color.Black
Me.DataGrid1.LinkColor = System.Drawing.Color.DarkGreen
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.ParentRowsBackColor = System.Drawing.Color.Gainsboro
Me.DataGrid1.ParentRowsForeColor = System.Drawing.Color.Black
Me.DataGrid1.SelectionBackColor = System.Drawing.Color.DarkSlateBlue
Me.DataGrid1.SelectionForeColor = System.Drawing.Color.White
Me.DataGrid1.Size = New System.Drawing.Size(430, 216)
Me.DataGrid1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(422, 213)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1})
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "用DataGrid显示数据的例子"
CType(Me.MyDataSet1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(MyDataSet1)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -