?? addindex.vb
字號:
Public Class frmAddIndex
Inherits System.Windows.Forms.Form
#Region " Windows 窗體設(shè)計器生成的代碼 "
Public Sub New()
MyBase.New()
'該調(diào)用是 Windows 窗體設(shè)計器所必需的。
InitializeComponent()
'在 InitializeComponent() 調(diào)用之后添加任何初始化
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 窗體設(shè)計器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下過程是 Windows 窗體設(shè)計器所必需的
'可以使用 Windows 窗體設(shè)計器修改此過程。
'不要使用代碼編輯器修改它。
Public WithEvents chkUnique As System.Windows.Forms.CheckBox
Public WithEvents chkPrimary As System.Windows.Forms.CheckBox
Public WithEvents chkIgnoreNulls As System.Windows.Forms.CheckBox
Public WithEvents txtIndexName As System.Windows.Forms.TextBox
Public WithEvents txtFields As System.Windows.Forms.TextBox
Public WithEvents lstFields As System.Windows.Forms.ListBox
Public WithEvents cmdOK As System.Windows.Forms.Button
Public WithEvents cmdClose As System.Windows.Forms.Button
Public WithEvents _lblLabels_2 As System.Windows.Forms.Label
Public WithEvents _lblLabels_1 As System.Windows.Forms.Label
Public WithEvents _lblLabels_0 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.chkUnique = New System.Windows.Forms.CheckBox()
Me.chkPrimary = New System.Windows.Forms.CheckBox()
Me.chkIgnoreNulls = New System.Windows.Forms.CheckBox()
Me.txtIndexName = New System.Windows.Forms.TextBox()
Me.txtFields = New System.Windows.Forms.TextBox()
Me.lstFields = New System.Windows.Forms.ListBox()
Me.cmdOK = New System.Windows.Forms.Button()
Me.cmdClose = New System.Windows.Forms.Button()
Me._lblLabels_2 = New System.Windows.Forms.Label()
Me._lblLabels_1 = New System.Windows.Forms.Label()
Me._lblLabels_0 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'chkUnique
'
Me.chkUnique.BackColor = System.Drawing.SystemColors.Control
Me.chkUnique.Checked = True
Me.chkUnique.CheckState = System.Windows.Forms.CheckState.Checked
Me.chkUnique.Cursor = System.Windows.Forms.Cursors.Default
Me.chkUnique.ForeColor = System.Drawing.SystemColors.ControlText
Me.chkUnique.Location = New System.Drawing.Point(206, 56)
Me.chkUnique.Name = "chkUnique"
Me.chkUnique.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.chkUnique.Size = New System.Drawing.Size(73, 17)
Me.chkUnique.TabIndex = 21
Me.chkUnique.Text = "唯一的"
'
'chkPrimary
'
Me.chkPrimary.BackColor = System.Drawing.SystemColors.Control
Me.chkPrimary.Checked = True
Me.chkPrimary.CheckState = System.Windows.Forms.CheckState.Checked
Me.chkPrimary.Cursor = System.Windows.Forms.Cursors.Default
Me.chkPrimary.ForeColor = System.Drawing.SystemColors.ControlText
Me.chkPrimary.Location = New System.Drawing.Point(206, 24)
Me.chkPrimary.Name = "chkPrimary"
Me.chkPrimary.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.chkPrimary.Size = New System.Drawing.Size(73, 17)
Me.chkPrimary.TabIndex = 20
Me.chkPrimary.Text = "主要的"
'
'chkIgnoreNulls
'
Me.chkIgnoreNulls.BackColor = System.Drawing.SystemColors.Control
Me.chkIgnoreNulls.Cursor = System.Windows.Forms.Cursors.Default
Me.chkIgnoreNulls.ForeColor = System.Drawing.SystemColors.ControlText
Me.chkIgnoreNulls.Location = New System.Drawing.Point(206, 82)
Me.chkIgnoreNulls.Name = "chkIgnoreNulls"
Me.chkIgnoreNulls.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.chkIgnoreNulls.Size = New System.Drawing.Size(81, 17)
Me.chkIgnoreNulls.TabIndex = 19
Me.chkIgnoreNulls.Text = "忽略空值"
'
'txtIndexName
'
Me.txtIndexName.AcceptsReturn = True
Me.txtIndexName.AutoSize = False
Me.txtIndexName.BackColor = System.Drawing.SystemColors.Window
Me.txtIndexName.Cursor = System.Windows.Forms.Cursors.IBeam
Me.txtIndexName.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtIndexName.Location = New System.Drawing.Point(6, 24)
Me.txtIndexName.MaxLength = 0
Me.txtIndexName.Name = "txtIndexName"
Me.txtIndexName.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.txtIndexName.Size = New System.Drawing.Size(185, 19)
Me.txtIndexName.TabIndex = 11
Me.txtIndexName.Text = ""
'
'txtFields
'
Me.txtFields.AcceptsReturn = True
Me.txtFields.AutoSize = False
Me.txtFields.BackColor = System.Drawing.SystemColors.Window
Me.txtFields.Cursor = System.Windows.Forms.Cursors.IBeam
Me.txtFields.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtFields.Location = New System.Drawing.Point(6, 64)
Me.txtFields.MaxLength = 0
Me.txtFields.Multiline = True
Me.txtFields.Name = "txtFields"
Me.txtFields.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.txtFields.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtFields.Size = New System.Drawing.Size(185, 35)
Me.txtFields.TabIndex = 12
Me.txtFields.Text = ""
'
'lstFields
'
Me.lstFields.BackColor = System.Drawing.SystemColors.Window
Me.lstFields.Cursor = System.Windows.Forms.Cursors.Default
Me.lstFields.ForeColor = System.Drawing.SystemColors.WindowText
Me.lstFields.ItemHeight = 12
Me.lstFields.Location = New System.Drawing.Point(6, 120)
Me.lstFields.Name = "lstFields"
Me.lstFields.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.lstFields.Size = New System.Drawing.Size(185, 88)
Me.lstFields.Sorted = True
Me.lstFields.TabIndex = 13
'
'cmdOK
'
Me.cmdOK.BackColor = System.Drawing.SystemColors.Control
Me.cmdOK.Cursor = System.Windows.Forms.Cursors.Default
Me.cmdOK.Enabled = False
Me.cmdOK.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdOK.Location = New System.Drawing.Point(206, 152)
Me.cmdOK.Name = "cmdOK"
Me.cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.cmdOK.Size = New System.Drawing.Size(81, 25)
Me.cmdOK.TabIndex = 14
Me.cmdOK.Text = "確定(&O)"
'
'cmdClose
'
Me.cmdClose.BackColor = System.Drawing.SystemColors.Control
Me.cmdClose.Cursor = System.Windows.Forms.Cursors.Default
Me.cmdClose.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.cmdClose.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdClose.Location = New System.Drawing.Point(206, 192)
Me.cmdClose.Name = "cmdClose"
Me.cmdClose.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.cmdClose.Size = New System.Drawing.Size(81, 25)
Me.cmdClose.TabIndex = 15
Me.cmdClose.Text = "關(guān)閉(&C)"
'
'_lblLabels_2
'
Me._lblLabels_2.AutoSize = True
Me._lblLabels_2.BackColor = System.Drawing.SystemColors.Control
Me._lblLabels_2.Cursor = System.Windows.Forms.Cursors.Default
Me._lblLabels_2.ForeColor = System.Drawing.SystemColors.ControlText
Me._lblLabels_2.Location = New System.Drawing.Point(6, 104)
Me._lblLabels_2.Name = "_lblLabels_2"
Me._lblLabels_2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._lblLabels_2.Size = New System.Drawing.Size(66, 14)
Me._lblLabels_2.TabIndex = 18
Me._lblLabels_2.Text = "可用字段:"
'
'_lblLabels_1
'
Me._lblLabels_1.AutoSize = True
Me._lblLabels_1.BackColor = System.Drawing.SystemColors.Control
Me._lblLabels_1.Cursor = System.Windows.Forms.Cursors.Default
Me._lblLabels_1.ForeColor = System.Drawing.SystemColors.ControlText
Me._lblLabels_1.Location = New System.Drawing.Point(6, 48)
Me._lblLabels_1.Name = "_lblLabels_1"
Me._lblLabels_1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._lblLabels_1.Size = New System.Drawing.Size(79, 14)
Me._lblLabels_1.TabIndex = 17
Me._lblLabels_1.Text = "索引的字段:"
'
'_lblLabels_0
'
Me._lblLabels_0.AutoSize = True
Me._lblLabels_0.BackColor = System.Drawing.SystemColors.Control
Me._lblLabels_0.Cursor = System.Windows.Forms.Cursors.Default
Me._lblLabels_0.ForeColor = System.Drawing.SystemColors.ControlText
Me._lblLabels_0.Location = New System.Drawing.Point(6, 8)
Me._lblLabels_0.Name = "_lblLabels_0"
Me._lblLabels_0.RightToLeft = System.Windows.Forms.RightToLeft.No
Me._lblLabels_0.Size = New System.Drawing.Size(42, 14)
Me._lblLabels_0.TabIndex = 16
Me._lblLabels_0.Text = "名稱:"
'
'frmAddIndex
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 221)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkUnique, Me.chkPrimary, Me.chkIgnoreNulls, Me.txtIndexName, Me.txtFields, Me.lstFields, Me.cmdOK, Me.cmdClose, Me._lblLabels_2, Me._lblLabels_1, Me._lblLabels_0})
Me.Name = "frmAddIndex"
Me.Text = "AddIndex"
Me.ResumeLayout(False)
End Sub
#End Region
'>>>>>>>>>>>>>>>>>>>>>>>>
Const FORMCAPTION As String = "添加索引"
Const BUTTON1 As String = "確定(&O)"
Const BUTTON2 As String = "關(guān)閉(&C)"
Const LABEL0 As String = "名稱:"
Const Label1 As String = "索引的字段:"
Const Label2 As String = "可用字段:"
'>>>>>>>>>>>>>>>>>>>>>>>>
Private Sub lstFields_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles lstFields.SelectedIndexChanged
Dim sTmp As String
sTmp = txtFields.Text
If Len(sTmp) = 0 Then
txtFields.Text = sTmp & lstFields.Text
Else
txtFields.Text = sTmp & ";" & lstFields.Text
End If
txtFields.Refresh()
End Sub
Private Sub txtFields_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtFields.TextChanged
cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
End Sub
Private Sub txtFields_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtFields.Leave
cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
End Sub
Private Sub txtIndexName_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIndexName.Leave
cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
End Sub
Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click
Me.Close()
End Sub
Private Sub frmAddIndex_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Dim tblTableDef As DAO.TableDef
Dim fld As DAO.Field
Dim i As Integer
Me.Text = FORMCAPTION
cmdOK.Text = BUTTON1
cmdClose.Text = BUTTON2
For i = 0 To MyRS.Fields.Count - 1 Step 1
lstFields.Items.Add(MyRS.Fields(i).Name)
Next
SetDefaults()
MyRS.Close()
End Sub
Private Sub txtIndexName_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIndexName.TextChanged
cmdOK.Enabled = Len(txtIndexName.Text) > 0 And Len(txtFields.Text) > 0
End Sub
Private Sub cmdOK_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOK.Click
Dim indIndexObj As DAO.Index
Dim tblTableDefObj As DAO.TableDef
Dim sTmp As String
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
indIndexObj = MyTD.CreateIndex(txtIndexName.Text)
With indIndexObj
.Fields = txtFields.Text
.Unique = chkUnique.CheckState
.Primary = IIf(chkPrimary.CheckState, True, False)
.IgnoreNulls = IIf(chkIgnoreNulls.CheckState = System.Windows.Forms.CheckState.Checked, True, False)
End With
'從 tblstruct 窗體中給全局 tabledef 追加索引
MyTD.Indexes.Append(indIndexObj)
'清除名稱并允許輸入下一個
SetDefaults()
txtIndexName.Focus()
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
End Sub
Private Sub SetDefaults()
txtIndexName.Text = vbNullString
txtFields.Text = vbNullString
chkUnique.CheckState = System.Windows.Forms.CheckState.Checked
End Sub
End Class
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -