?? frmbase.vb
字號:
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 15)
Me.Label2.TabIndex = 3
Me.Label2.Text = " 年級"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(88, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 15)
Me.Label1.TabIndex = 2
Me.Label1.Text = "班級編號"
'
'txbOne
'
Me.txbOne.Location = New System.Drawing.Point(144, 11)
Me.txbOne.Name = "txbOne"
Me.txbOne.Size = New System.Drawing.Size(112, 21)
Me.txbOne.TabIndex = 1
Me.txbOne.Text = ""
'
'btnSearch
'
Me.btnSearch.Image = CType(resources.GetObject("btnSearch.Image"), System.Drawing.Image)
Me.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.btnSearch.Location = New System.Drawing.Point(16, 12)
Me.btnSearch.Name = "btnSearch"
Me.btnSearch.Size = New System.Drawing.Size(64, 22)
Me.btnSearch.TabIndex = 0
Me.btnSearch.Text = " 搜索"
'
'lblCount
'
Me.lblCount.Location = New System.Drawing.Point(488, 15)
Me.lblCount.Name = "lblCount"
Me.lblCount.Size = New System.Drawing.Size(104, 12)
Me.lblCount.TabIndex = 4
'
'dgdList
'
Me.dgdList.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.dgdList.CaptionVisible = False
Me.dgdList.DataMember = ""
Me.dgdList.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dgdList.Location = New System.Drawing.Point(5, 80)
Me.dgdList.Name = "dgdList"
Me.dgdList.Size = New System.Drawing.Size(603, 88)
Me.dgdList.TabIndex = 3
'
'frmBase
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(608, 277)
Me.Controls.Add(Me.dgdList)
Me.Controls.Add(Me.grbSearch)
Me.Controls.Add(Me.ToolBar1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmBase"
Me.Text = "frmBase"
Me.grbSearch.ResumeLayout(False)
CType(Me.dgdList, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmBase_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Prepare()
SetDataGrid()
SetTextBoxState(True)
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As Object, _
ByVal e As ToolBarButtonClickEventArgs) _
Handles ToolBar1.ButtonClick
Select Case e.Button.Text
Case "首記錄"
'返回首記錄
bmData.Position = 0
Case "上記錄"
If bmData.Position <> 0 Then
bmData.Position -= 1
End If
Case "下記錄"
If bmData.Position <> bmData.Count Then
bmData.Position += 1
End If
Case "尾記錄"
'返回尾記錄
bmData.Position = bmData.Count
Case "新增"
Me.dgdList.Enabled = False
SetTextBoxState(False)
SetToolBarState(False)
bAdd = True
Clear()
Case "修改"
Me.dgdList.Enabled = False
SetTextBoxState(False)
SetToolBarState(False)
bAdd = False
Case "刪除"
'彈出詢問對話框
Dim dlgResult As DialogResult = _
MessageBox.Show("你確認刪除此數據?", _
"刪除", MessageBoxButtons.OKCancel)
If dlgResult = DialogResult.OK Then
DeleteData()
End If
Case "保存"
SetToolBarState(True)
SetTextBoxState(True)
If bAdd = True Then
'為新增數據保存
SaveForAdd()
Else
'為更新數據保存
SaveForUpdate()
End If
Me.dgdList.Enabled = True
Case "取消"
SetTextBoxState(True)
SetToolBarState(True)
Me.dgdList.Enabled = True
SearchResult()
Case "退出"
'關閉本窗體
Me.Close()
End Select
Try
Me.dgdList.CurrentRowIndex = bmData.Position
SetData()
Catch ex As Exception
End Try
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSearch.Click
SearchResult()
End Sub
Private Sub dgdList_CurrentCellChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles dgdList.CurrentCellChanged
Try
'判斷bmData是否為Nothing
If bmData Is Nothing Then
Exit Sub
End If
If bmData.Position <> dgdList.CurrentCell.RowNumber Then
bmData.Position = dgdList.CurrentCell.RowNumber
SetData()
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Private Sub SetToolBarState(ByVal bState As Boolean)
'設置Button的是否能夠單擊
ToolBar1.Buttons("0").Enabled = bState
ToolBar1.Buttons("1").Enabled = bState
ToolBar1.Buttons("2").Enabled = bState
ToolBar1.Buttons("3").Enabled = bState
ToolBar1.Buttons("4").Enabled = bState
ToolBar1.Buttons("5").Enabled = bState
ToolBar1.Buttons("6").Enabled = bState
ToolBar1.Buttons("7").Enabled = Not bState
ToolBar1.Buttons("8").Enabled = Not bState
End Sub
Public Overridable Sub Prepare()
End Sub
'設置DataGrid控件
Public Overridable Sub SetDataGrid()
End Sub
'查詢函數
Public Overridable Sub SearchResult()
SetDataGrid()
' dgdList.DataSource = dtData.DefaultView
End Sub
'新增函數
Public Overridable Sub LoadData()
End Sub
Public Overridable Sub SaveForAdd()
End Sub
'更新函數
Public Overridable Sub SaveForUpdate()
End Sub
'刪除函數
Public Overridable Sub DeleteData()
End Sub
'清除函數
Public Overridable Sub Clear()
End Sub
'設置TextBox函數
Public Overridable Sub SetTextBoxState(ByVal bState As Boolean)
End Sub
Public Overridable Sub SetData()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -