?? form1.frm
字號:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form form1
Caption = "在DBGrid中實現下拉菜單輸入和單元格計算"
ClientHeight = 3465
ClientLeft = 60
ClientTop = 345
ClientWidth = 6315
LinkTopic = "Form1"
ScaleHeight = 3465
ScaleWidth = 6315
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command1
Caption = "退出"
Height = 345
Left = 3900
TabIndex = 2
Top = 2940
Width = 2115
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "E:\編程技巧\xcx\數據庫\66在DBGRID控件的單元格中實現下拉列表框。\path.mdb"
DefaultCursorType= 0 '缺省游標
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 345
Left = 810
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "path"
Top = 2910
Visible = 0 'False
Width = 1605
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "form1.frx":0000
Left = 630
List = "form1.frx":0010
TabIndex = 1
Text = "12"
Top = 540
Width = 2055
End
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "form1.frx":0024
Height = 2490
Left = 210
OleObjectBlob = "form1.frx":0038
TabIndex = 0
Top = 240
Width = 5865
End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Activate()
DBGrid1.Columns(0).Width = 1800
DBGrid1.Columns(1).Width = 700
DBGrid1.Columns(2).Width = 700
DBGrid1.Columns(3).Width = 1800
End Sub
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\path.mdb"
DBGrid1.RowHeight = Combo1.Height
Combo1.Visible = False
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Combo1.Width = DBGrid1.Columns(DBGrid1.Col).Width
Combo1.Left = DBGrid1.Left + DBGrid1.Columns(DBGrid1.Col + 1).Left
Combo1.Top = DBGrid1.Top + DBGrid1.Row * DBGrid1.RowHeight + 225
DBGrid1.Text = Combo1.Text
DBGrid1.Col = DBGrid1.Col + 1
DBGrid1.SetFocus
End If
End Sub
Private Sub DBGrid1_Click()
If DBGrid1.Col = 1 Then
Combo1.Visible = True
Combo1.Width = DBGrid1.Columns(DBGrid1.Col).Width
Combo1.Left = DBGrid1.Left + DBGrid1.Columns(DBGrid1.Col).Left
Combo1.Top = DBGrid1.Top + DBGrid1.Row * DBGrid1.RowHeight + 225
Else
Combo1.Visible = False
End If
End Sub
Private Sub DBGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
DBGrid1.Columns(3) = Val(DBGrid1.Columns(1)) * Val(DBGrid1.Columns(2))
If DBGrid1.Col = 2 Then
DBGrid1.Row = DBGrid1.Row + 1
DBGrid1.Col = 0
End If
End If
End Sub
Private Sub DBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
If DBGrid1.Col = 1 Then
Combo1.Visible = True
Combo1.Width = DBGrid1.Columns(DBGrid1.Col).Width
Combo1.Left = DBGrid1.Left + DBGrid1.Columns(DBGrid1.Col).Left
Combo1.Top = DBGrid1.Top + DBGrid1.Row * DBGrid1.RowHeight + 225
Else
Combo1.Visible = False
End If
End Sub
Private Sub Command1_Click()
End
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -