?? frmbase.vb
字號(hào):
Public Class frmBase
Inherits System.Windows.Forms.Form
Protected bmData As BindingManagerBase
Protected dtData As DataTable
'bAdd = true 為新增
'bAdd = false 為修改
Protected bAdd As Boolean
#Region " Windows 窗體設(shè)計(jì)器生成的代碼 "
Public Sub New()
MyBase.New()
'該調(diào)用是 Windows 窗體設(shè)計(jì)器所必需的。
InitializeComponent()
'在 InitializeComponent() 調(diào)用之后添加任何初始化
End Sub
'窗體重寫(xiě) 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
'注意: 以下過(guò)程是 Windows 窗體設(shè)計(jì)器所必需的
'可以使用 Windows 窗體設(shè)計(jì)器修改此過(guò)程。
'不要使用代碼編輯器修改它。
Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents tbbFirst As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbBack As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbForward As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbLast As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbNew As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbModify As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbDel As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbSave As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbUndo As System.Windows.Forms.ToolBarButton
Friend WithEvents tbbExit As System.Windows.Forms.ToolBarButton
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents grbSearch As System.Windows.Forms.GroupBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btnSearch As System.Windows.Forms.Button
Friend WithEvents dgdList As System.Windows.Forms.DataGrid
Friend WithEvents txbThree As System.Windows.Forms.TextBox
Friend WithEvents txbTwo As System.Windows.Forms.TextBox
Friend WithEvents txbOne As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmBase))
Me.ToolBar1 = New System.Windows.Forms.ToolBar
Me.tbbFirst = New System.Windows.Forms.ToolBarButton
Me.tbbBack = New System.Windows.Forms.ToolBarButton
Me.tbbForward = New System.Windows.Forms.ToolBarButton
Me.tbbLast = New System.Windows.Forms.ToolBarButton
Me.tbbNew = New System.Windows.Forms.ToolBarButton
Me.tbbModify = New System.Windows.Forms.ToolBarButton
Me.tbbDel = New System.Windows.Forms.ToolBarButton
Me.tbbSave = New System.Windows.Forms.ToolBarButton
Me.tbbUndo = New System.Windows.Forms.ToolBarButton
Me.tbbExit = New System.Windows.Forms.ToolBarButton
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.grbSearch = New System.Windows.Forms.GroupBox
Me.Label3 = New System.Windows.Forms.Label
Me.txbThree = New System.Windows.Forms.TextBox
Me.txbTwo = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.txbOne = New System.Windows.Forms.TextBox
Me.btnSearch = New System.Windows.Forms.Button
Me.dgdList = New System.Windows.Forms.DataGrid
Me.grbSearch.SuspendLayout()
CType(Me.dgdList, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbbFirst, Me.tbbBack, Me.tbbForward, Me.tbbLast, Me.tbbNew, Me.tbbModify, Me.tbbDel, Me.tbbSave, Me.tbbUndo, Me.tbbExit})
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.ImageList = Me.ImageList1
Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(536, 41)
Me.ToolBar1.TabIndex = 1
'
'tbbFirst
'
Me.tbbFirst.ImageIndex = 0
Me.tbbFirst.Text = "首記錄"
Me.tbbFirst.ToolTipText = "首記錄"
'
'tbbBack
'
Me.tbbBack.ImageIndex = 1
Me.tbbBack.Text = "上記錄"
Me.tbbBack.ToolTipText = "上一條記錄"
'
'tbbForward
'
Me.tbbForward.ImageIndex = 2
Me.tbbForward.Text = "下記錄"
Me.tbbForward.ToolTipText = "下一條記錄"
'
'tbbLast
'
Me.tbbLast.ImageIndex = 3
Me.tbbLast.Text = "尾記錄"
Me.tbbLast.ToolTipText = "尾記錄"
'
'tbbNew
'
Me.tbbNew.ImageIndex = 4
Me.tbbNew.Text = "新增"
Me.tbbNew.ToolTipText = "新增"
'
'tbbModify
'
Me.tbbModify.ImageIndex = 5
Me.tbbModify.Text = "修改"
Me.tbbModify.ToolTipText = "修改"
'
'tbbDel
'
Me.tbbDel.ImageIndex = 6
Me.tbbDel.Text = "刪除"
Me.tbbDel.ToolTipText = "刪除"
'
'tbbSave
'
Me.tbbSave.Enabled = False
Me.tbbSave.ImageIndex = 7
Me.tbbSave.Text = "保存"
Me.tbbSave.ToolTipText = "保存"
'
'tbbUndo
'
Me.tbbUndo.Enabled = False
Me.tbbUndo.ImageIndex = 8
Me.tbbUndo.Text = "取消"
Me.tbbUndo.ToolTipText = "取消"
'
'tbbExit
'
Me.tbbExit.ImageIndex = 9
Me.tbbExit.Text = "退出"
Me.tbbExit.ToolTipText = "退出"
'
'ImageList1
'
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
'
'grbSearch
'
Me.grbSearch.Controls.Add(Me.Label3)
Me.grbSearch.Controls.Add(Me.txbThree)
Me.grbSearch.Controls.Add(Me.txbTwo)
Me.grbSearch.Controls.Add(Me.Label2)
Me.grbSearch.Controls.Add(Me.Label1)
Me.grbSearch.Controls.Add(Me.txbOne)
Me.grbSearch.Controls.Add(Me.btnSearch)
Me.grbSearch.Dock = System.Windows.Forms.DockStyle.Top
Me.grbSearch.Location = New System.Drawing.Point(0, 41)
Me.grbSearch.Name = "grbSearch"
Me.grbSearch.Size = New System.Drawing.Size(536, 39)
Me.grbSearch.TabIndex = 2
Me.grbSearch.TabStop = False
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(320, 16)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 15)
Me.Label3.TabIndex = 6
Me.Label3.Text = "物料拼音"
'
'txbThree
'
Me.txbThree.Location = New System.Drawing.Point(376, 11)
Me.txbThree.Name = "txbThree"
Me.txbThree.Size = New System.Drawing.Size(56, 21)
Me.txbThree.TabIndex = 5
Me.txbThree.Text = ""
'
'txbTwo
'
Me.txbTwo.Location = New System.Drawing.Point(248, 11)
Me.txbTwo.Name = "txbTwo"
Me.txbTwo.Size = New System.Drawing.Size(56, 21)
Me.txbTwo.TabIndex = 4
Me.txbTwo.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(192, 16)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 15)
Me.Label2.TabIndex = 3
Me.Label2.Text = "物料名稱(chēng)"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(72, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 15)
Me.Label1.TabIndex = 2
Me.Label1.Text = "物料編號(hào)"
'
'txbOne
'
Me.txbOne.Location = New System.Drawing.Point(128, 11)
Me.txbOne.Name = "txbOne"
Me.txbOne.Size = New System.Drawing.Size(56, 21)
Me.txbOne.TabIndex = 1
Me.txbOne.Text = ""
'
'btnSearch
'
Me.btnSearch.Location = New System.Drawing.Point(8, 11)
Me.btnSearch.Name = "btnSearch"
Me.btnSearch.Size = New System.Drawing.Size(40, 22)
Me.btnSearch.TabIndex = 0
Me.btnSearch.Text = "搜索"
'
'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(0, 80)
Me.dgdList.Name = "dgdList"
Me.dgdList.Size = New System.Drawing.Size(208, 213)
Me.dgdList.TabIndex = 3
'
'frmBase
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(536, 293)
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 System.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 "新增"
SetTextBoxState(False)
SetToolBarState(False)
SetOpenButton(True)
bAdd = True
Clear()
Case "修改"
SetTextBoxState(False)
SetToolBarState(False)
SetOpenButton(True)
bAdd = False
Case "刪除"
'彈出詢(xún)問(wèn)對(duì)話框
Dim dlgResult As DialogResult = _
MessageBox.Show("你確認(rèn)刪除此數(shù)據(jù)?", _
"刪除", MessageBoxButtons.OKCancel)
If dlgResult = DialogResult.OK Then
DeleteData()
End If
Case "保存"
SetToolBarState(True)
SetTextBoxState(True)
SetOpenButton(False)
If bAdd = True Then
'為新增數(shù)據(jù)保存
SaveForAdd()
Else
'為更新數(shù)據(jù)保存
SaveForUpdate()
End If
Case "取消"
SetTextBoxState(True)
SetToolBarState(True)
If Me.Name = "frmProductsDemand" Then
SetOpenButton(False)
End If
Case "退出"
'關(guān)閉本窗體
Me.Close()
End Select
Try
Me.dgdList.CurrentRowIndex = bmData.Position
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
'判斷bmData是否為Nothing
If bmData Is Nothing Then
Exit Sub
End If
If bmData.Position <> dgdList.CurrentCell.RowNumber Then
bmData.Position = dgdList.CurrentCell.RowNumber
SetProductName()
End If
End Sub
Private Sub SetToolBarState(ByVal bState As Boolean)
'設(shè)置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
'設(shè)置DataGrid控件
Public Overridable Sub SetDataGrid()
End Sub
'查詢(xún)函數(shù)
Public Overridable Sub SearchResult()
End Sub
'新增函數(shù)
Public Overridable Sub SaveForAdd()
End Sub
'更新函數(shù)
Public Overridable Sub SaveForUpdate()
End Sub
'刪除函數(shù)
Public Overridable Sub DeleteData()
End Sub
'清除函數(shù)
Public Overridable Sub Clear()
End Sub
'設(shè)置按鈕函數(shù)
Public Overridable Sub SetOpenButton(ByVal bEnable As Boolean)
End Sub
Public Overridable Sub SetProductName()
End Sub
'設(shè)置TextBox函數(shù)
Public Overridable Sub SetTextBoxState(ByVal bState As Boolean)
End Sub
End Class
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -