Public Rs As New ADODB.Recordset
Public Conn As New ADODB.Connection
Public CellRow As Double '定义当前鼠标的坐标 x
Public CellCol As Double ' y
Dim NowText As String
Public Sub ConnOpen() '打开数据库
On Error GoTo ConnOpenError
Conn.ConnectionString = "driver={sql server};server=(local);uid=sq_fjy;pwd=3303321DanDan520;database=sq_fjy"
Conn.Open
Exit Sub
ConnOpenError: MsgBox Err.Description
End Sub
Public Sub ConnClose() '关闭数据库
On Error GoTo ConnCloseError
If Conn.State = 1 Then
Conn.Close
Set Conn = Nothing
End If
Exit Sub
ConnCloseError: MsgBox Err.Description
End Sub
Private Sub FGrid_Click()
CellRow = FGrid.Row '保存当前鼠标坐标值
CellCol = FGrid.Col
Call ShowEdit(TxtInNum) '借用进户数输入框为配件数量输入
End Sub
Sub ShowEdit(control As control)
CellRow = FGrid.Row '对当前鼠标进行捕捉
CellCol = FGrid.Col '
NowText = FGrid.TextMatrix(CellRow, CellCol) ' 记录中 grid2 当前单元格中的字符串
With FGrid
.RowSel = .Row
.ColSel = .Col
'下面是把下拉框 combo1 移到当前单元格
control.Move .Left + .CellLeft, .Top + .CellTop, _
.CellWidth - ScaleX(1, vbPixels, vbTwips)
control.Visible = True '下拉框 combo1 的 visible 属性设为可见--true
control.BackColor = &H80000018
control.ZOrder
control.SetFocus
control.SelStart = 0
control.SelLength = Len(control.Text)
' If nowtext = "" Then
' Control.Visible = False
' Else
control.Text = NowText '下拉框combo1 未被选择时显示原有的grid2中单元格的内容
' End If
CellRow = .Row '当前鼠标坐标赋值 X
CellCol = .Col ' Y
End With
End Sub
Private Sub FGrid_KeyDown(KeyCode As Integer, Shift As Integer)
Call ShowEdit(TxtInNum)
End Sub
Private Sub TxtInNum_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Or KeyCode = 13 Then
'MsgBox KeyCode
TxtInNum.Visible = False
End If
End Sub

浙公网安备 33010602011771号