📄 grdedemo.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmGridEditDemo
BorderStyle = 3 'Fixed Dialog
Caption = "Grid Edit Demo"
ClientHeight = 4125
ClientLeft = 1425
ClientTop = 1710
ClientWidth = 7110
Icon = "GrdEDemo.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4125
ScaleWidth = 7110
Begin VB.CheckBox chkEditable
Caption = "&Editable"
ForeColor = &H00C00000&
Height = 180
Left = 4230
TabIndex = 7
Top = 3810
Value = 1 'Checked
Width = 1185
End
Begin VB.Frame Frame1
Height = 2715
Left = 105
TabIndex = 0
Top = -15
Width = 6900
Begin VB.TextBox Text1
BackColor = &H0000FFFF&
Height = 270
Left = 1050
TabIndex = 2
Top = 825
Visible = 0 'False
Width = 855
End
Begin VB.ComboBox Combo1
BackColor = &H0000FFFF&
Height = 300
ItemData = "GrdEDemo.frx":0442
Left = 1950
List = "GrdEDemo.frx":0444
TabIndex = 3
Text = "Combo1"
Top = 1080
Visible = 0 'False
Width = 855
End
Begin VB.ComboBox Combo2
BackColor = &H0000FFFF&
Height = 300
ItemData = "GrdEDemo.frx":0446
Left = 2850
List = "GrdEDemo.frx":0448
Style = 2 'Dropdown List
TabIndex = 4
Top = 1335
Visible = 0 'False
Width = 855
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 2490
Left = 60
TabIndex = 1
Top = 150
Width = 6780
_ExtentX = 11959
_ExtentY = 4392
_Version = 327680
RowHeightMin = 255
BackColor = 16777215
ForeColor = 8388608
ForeColorFixed = 0
BackColorSel = 8388608
ForeColorSel = 16777215
ScrollTrack = -1 'True
End
End
Begin VB.TextBox txtMsg
ForeColor = &H00000000&
Height = 840
Left = 105
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 5
Top = 2790
Width = 6900
End
Begin VB.CommandButton cmdExit
Caption = "E&xit"
Height = 315
Left = 5745
TabIndex = 8
Top = 3735
Width = 1200
End
Begin VB.Label lblAbout
AutoSize = -1 'True
Caption = "Friends - Wang Jingyu May 31,1998"
BeginProperty Font
Name = "Times New Roman"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00808000&
Height = 285
Left = 195
TabIndex = 6
Top = 3735
Width = 3690
End
End
Attribute VB_Name = "frmGridEditDemo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private GE As New clsGridEdit
Private Sub chkEditable_Click()
chkEditable.ForeColor = IIf(chkEditable.Value = vbChecked, vbBlue, vbBlack)
GE.Editable = (chkEditable.Value = vbChecked)
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Combo1_Change()
GE.cboChange
End Sub
Private Sub Combo1_Click()
GE.cboChange
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
GE.cboKeyDown KeyCode, Shift
End Sub
Private Sub Combo1_LostFocus()
Combo1.Visible = False
End Sub
Private Sub Combo2_Change()
GE.cboChange
End Sub
Private Sub Combo2_Click()
GE.cboChange
End Sub
Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
GE.cboKeyDown KeyCode, Shift
End Sub
Private Sub Combo2_LostFocus()
Combo2.Visible = False
End Sub
Private Sub Form_Load()
Dim I As Integer
Dim J As Integer
Dim Msg As String
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
Msg = "This grid edit demo show you how to use MSFlexGrid as a editable grid."
Msg = Msg & vbCrLf & "You can use TextBox and ComboBox to edit."
Msg = Msg & vbCrLf & "Change row:"
Msg = Msg & vbCrLf & "<PageUp>, <PageDown>, <UpArrow>, <DownArrow>"
Msg = Msg & vbCrLf & "Change col:"
Msg = Msg & vbCrLf & "<Ctrl-Home>, <Ctrl-End>, <Ctrl-LeftArrow>, <Ctrl-RightArrow>, <Enter>"
txtMsg = Msg
Me.Show
Me.Refresh
Randomize
With MSFlexGrid1
.Redraw = False
.Rows = 51
.Cols = 21
.FixedRows = 1
.FixedCols = 1
.TextMatrix(0, 0) = "Grid Edit"
.ColAlignment(0) = 4
For I = 1 To .Cols - 1
.ColWidth(I) = 15 * (40 + Int(Rnd * 60))
.FixedAlignment(I) = 4
.TextMatrix(0, I) = "Col " & I
.ColAlignment(I) = 3 + ((I - 1) Mod 3)
Next I
For I = 1 To .Rows - 1
.TextMatrix(I, 0) = "Row " & I
Next I
For I = 1 To .Rows - 1
For J = 1 To .Cols - 1
.TextMatrix(I, J) = I & "," & J
Next J
Next I
.Row = .FixedRows
.Col = .FixedCols
For I = .FixedRows To .Rows - 1
For J = .FixedCols To .Cols - 1
Combo1.AddItem I & "," & J
Combo2.AddItem I & "," & J
Next J
Next I
.Redraw = True
End With
GE.grdInit MSFlexGrid1, Text1
For I = 4 To 6
GE.cboInit Combo1, I
Next I
For I = 10 To 12
GE.cboInit Combo2, I
Next I
GE.ColEditable(2) = False
GE.ColEditable(3) = False
GE.ColEditable(7) = False
GE.ColEditable(9) = False
GE.ColEditable(18) = False
GE.ColEditable(19) = False
GE.RowsPerPage = 6
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub MSFlexGrid1_GotFocus()
GE.grdGotFocus
End Sub
Private Sub MSFlexGrid1_Scroll()
GE.grdScroll
End Sub
Private Sub Text1_Change()
GE.txtChange
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
GE.txtKeyDown KeyCode, Shift
End Sub
Private Sub Text1_LostFocus()
Text1.Visible = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -