?? dataform1.vb
字號(hào):
Public Class DataForm1
Inherits System.Windows.Forms.Form
#Region " Windows 窗體設(shè)計(jì)器生成的代碼 "
Public Sub New()
MyBase.New()
'該調(diào)用是 Windows 窗體設(shè)計(jì)器所必需的。
InitializeComponent()
'在 InitializeComponent() 調(diào)用之后添加任何初始化
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 窗體設(shè)計(jì)器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下過程是 Windows 窗體設(shè)計(jì)器所必需的
'可以使用 Windows 窗體設(shè)計(jì)器修改此過程。
'不要使用代碼編輯器修改它。
Friend WithEvents objDataSet1 As WindowsApplication1.DataSet1
Friend WithEvents btnLoad As System.Windows.Forms.Button
Friend WithEvents grddetail As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.objDataSet1 = New WindowsApplication1.DataSet1
Me.btnLoad = New System.Windows.Forms.Button
Me.grddetail = New System.Windows.Forms.DataGrid
CType(Me.objDataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.grddetail, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'objDataSet1
'
Me.objDataSet1.DataSetName = "DataSet1"
Me.objDataSet1.Locale = New System.Globalization.CultureInfo("zh-CN")
'
'btnLoad
'
Me.btnLoad.Location = New System.Drawing.Point(10, 10)
Me.btnLoad.Name = "btnLoad"
Me.btnLoad.Size = New System.Drawing.Size(88, 23)
Me.btnLoad.TabIndex = 0
Me.btnLoad.Text = "加載(&L)"
'
'grddetail
'
Me.grddetail.DataMember = "detail"
Me.grddetail.DataSource = Me.objDataSet1
Me.grddetail.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.grddetail.Location = New System.Drawing.Point(10, 43)
Me.grddetail.Name = "grddetail"
Me.grddetail.Size = New System.Drawing.Size(380, 197)
Me.grddetail.TabIndex = 1
'
'DataForm1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(392, 223)
Me.Controls.Add(Me.btnLoad)
Me.Controls.Add(Me.grddetail)
Me.Name = "DataForm1"
Me.Text = "DataForm1"
CType(Me.objDataSet1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.grddetail, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Try
'嘗試加載數(shù)據(jù)集。
Me.LoadDataSet()
Catch eLoad As System.Exception
'在此處添加錯(cuò)誤處理代碼。
'顯示錯(cuò)誤信息(如果有)。
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
End Sub
Public Sub LoadDataSet()
'創(chuàng)建一個(gè)新數(shù)據(jù)集以保存從 FillDataSet 調(diào)用返回的記錄。
'使用了一個(gè)臨時(shí)數(shù)據(jù)集,這是因?yàn)樘畛洮F(xiàn)有的數(shù)據(jù)集
'需要重新綁定數(shù)據(jù)綁定。
Dim objDataSetTemp As WindowsApplication1.DataSet1
objDataSetTemp = New WindowsApplication1.DataSet1
Try
'嘗試填充臨時(shí)數(shù)據(jù)集。
objDataSetTemp = CType(Me.objDataSet1.Clone, WindowsApplication1.DataSet1)
Catch eFillDataSet As System.Exception
'在此處添加錯(cuò)誤處理代碼。
Throw eFillDataSet
End Try
Try
grddetail.DataSource = Nothing
'清空數(shù)據(jù)集中的舊記錄。
objDataSet1.Clear()
'將記錄合并到主數(shù)據(jù)集中。
objDataSet1.Merge(objDataSetTemp)
grddetail.SetDataBinding(objDataSet1, "detail")
Catch eLoadMerge As System.Exception
'在此處添加錯(cuò)誤處理代碼。
Throw eLoadMerge
End Try
End Sub
End Class
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -