📄 gridlister.frm
字号:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Grid Lister"
ClientHeight = 3150
ClientLeft = 1440
ClientTop = 2325
ClientWidth = 6420
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3150
ScaleWidth = 6420
Begin VB.TextBox txtProductId
DataField = "ProductID"
DataSource = "datProducts"
Enabled = 0 'False
Height = 285
Left = 3960
TabIndex = 5
Top = 360
Width = 1455
End
Begin VB.TextBox txtUnitsInStock
DataField = "UnitsInStock"
DataSource = "datProducts"
Enabled = 0 'False
Height = 285
Left = 2400
TabIndex = 4
Top = 360
Width = 1335
End
Begin VB.Data datOrderDetails
Caption = "Order Details"
Connect = "Access"
DatabaseName = "D:\Program Files\Microsoft Visual Studio\VB6\Nwind.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 465
Left = 3720
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Order Details"
Top = 2640
Visible = 0 'False
Width = 2535
End
Begin VB.TextBox txtProductName
DataField = "ProductName"
DataSource = "datProducts"
Enabled = 0 'False
Height = 285
Left = 120
MultiLine = -1 'True
TabIndex = 0
Top = 360
Width = 2055
End
Begin VB.Data datProducts
Caption = "Products"
Connect = "Access"
DatabaseName = "D:\Program Files\Microsoft Visual Studio\VB6\Nwind.mdb"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 465
Left = 120
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "Products"
Top = 2640
Width = 2535
End
Begin MSDBGrid.DBGrid dbgOrderDetails
Bindings = "GridLister.frx":0000
Height = 1575
Left = 120
OleObjectBlob = "GridLister.frx":001A
TabIndex = 6
Top = 960
Width = 6255
End
Begin VB.Label Label3
Caption = "Product ID"
Height = 255
Left = 3960
TabIndex = 3
Top = 120
Width = 1575
End
Begin VB.Label Label2
Caption = "Units in Stock"
Height = 255
Left = 2400
TabIndex = 2
Top = 120
Width = 1335
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "Product Name:"
Height = 195
Left = 120
TabIndex = 1
Top = 120
Width = 1275
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub datProducts_Reposition()
Dim strSql As String
If datProducts.Recordset.RecordCount = 0 Then
' Don't re-query the Order Details if there are
' no products displayed.
Exit Sub
End If
' Re-query the Order Detail grid by SQL SELECT statement.
' The WHERE clause picks up only the order details for
' the displayed product.
strSql = "SELECT * FROM [Order Details] WHERE ProductID = " _
& datProducts.Recordset.Fields("ProductID")
' Assign the desired SQL statement as the record source.
datOrderDetails.RecordSource = strSql
' Re-query the database to bring new data to the recordset
datOrderDetails.Refresh
' Set the default value for ProductID for any possible future
' Order Details inserts to the displayed product ID.
dbgOrderDetails.Columns("ProductID").DefaultValue = _
datProducts.Recordset.Fields("ProductID")
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -