; ''弹出菜单
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
''使第一列较窄。
flex1.ColWidth(0) = flex1.ColWidth(0) / 2
''初始化编辑框
txtEdit = ""
flex1.Rows = 101
flex1.Cols = 8
''设置列标头。
s$ = "^|^商品名称 |^规格 |^单位 |^数量 |^进货价 |^金额 |^备注 "
flex1.FormatString = s$
End Sub
Private Sub flex1_KeyPress(KeyAscii As Integer)
If flex1.Col >= 4 Or flex1.Col = 1 Then
MSHFlexGridEdit flex1, txtEdit, KeyAscii
End If
End Sub
''添加下列例程以初始化文本框,并将焦点从 Hierarchical FlexGrid 传递到 TextBox 控件:
Sub MSHFlexGridEdit(MSHFlexGrid As Control, Edt As Control, KeyAscii As Integer)
''使用已输入的字符。
Select Case KeyAscii
''空格表示编辑当前的文本。
Case 0 To 32
Edt = MSHFlexGrid
Edt.SelStart = 1000
''其它所有字符表示取代当前的文本。
Case Else
Edt = Chr(KeyAscii)
Edt.SelStart = 1
End Select
''在合适的位置显示 Edt。
Edt.Move MSHFlexGrid.Left + MSHFlexGrid.CellLeft - 15, _
MSHFlexGrid.Top + MSHFlexGrid.CellTop - 15, _
MSHFlexGrid.CellWidth, _
MSHFlexGrid.CellHeight
Edt.Visible = True
Edt.SetFocus
End Sub
Private Sub flex1_DblClick()
If flex1.Col >= 4 Or flex1.Col = 1 Then
MSHFlexGridEdit flex1, txtEdit, 32 ''模拟一个空格。
End If
End Sub
Private Sub lblSum_Click()
End Sub
Private Sub txt1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Index = 0 Then
Adodc1.RecordSource = "