📄 gridchange.frm
字号:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Grid Change"
ClientHeight = 3060
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 = 3060
ScaleWidth = 6420
Begin VB.CommandButton cmdChangeGridCell
Caption = "Change Qty"
Height = 375
Left = 4800
TabIndex = 9
Top = 2160
Width = 1455
End
Begin VB.TextBox txtChangeQuantity
Height = 285
Left = 3360
TabIndex = 8
Top = 2160
Width = 1215
End
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 = 2520
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 = 2520
Width = 2535
End
Begin MSDBGrid.DBGrid dbgOrderDetails
Bindings = "GridChange.frx":0000
Height = 1335
Left = 120
OleObjectBlob = "GridChange.frx":001A
TabIndex = 6
Top = 720
Width = 6255
End
Begin VB.Label Label4
Caption = "Change highlighted Quantity to ..."
Height = 255
Left = 120
TabIndex = 7
Top = 2160
Width = 3015
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 Utility As New clsUtility
Private Sub cmdChangeGridCell_Click()
' Change the selected grid cell value to the entered value
If Not IsNumeric(txtChangeQuantity.Text) Then
MsgBox "Change quantity must be a positive number", vbInformation
ElseIf CInt(txtChangeQuantity.Text) < 0 Then
MsgBox "Change quantity must be a positive number", vbInformation
Else
dbgOrderDetails.Columns("Quantity").Text = txtChangeQuantity.Text
End If
End Sub
Private Sub datProducts_Reposition()
Dim strSql As String
If datProducts.Recordset.RecordCount = 0 Then
' Get out of Dodge if there aren't any products
Exit Sub
End If
' Update 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")
datOrderDetails.RecordSource = strSql
datOrderDetails.Refresh
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 + -