加了一个Combo3,根据行列改变位置Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
'If DataGrid1.Enabled = True Then
' If Not Rs_J_Pctzd_Sp.EOF Then
' If DataGrid1.Col = 1 Or DataGrid1.Col = 3 Or DataGrid1.Col = 4 Then
' If DataGrid1.Columns(3).Text <> "" And DataGrid1.Columns(1).Text <> "" Then
' DataGrid1.Columns(4).Text = Round(DataGrid1.Columns(3).Text * DataGrid1.Columns(1).Text, 2)
' End If
' End If
' End If
'End If
Dim Xh As Integer
Dim cSpdj1 As Double
If DataGrid1.Enabled = True Then
If Not Rs_J_Pctzd_Sp.EOF Then
If DataGrid1.Col = 1 Or DataGrid1.Col = 3 Or DataGrid1.Col = 4 Then
If DataGrid1.Columns(3).Text <> "" And DataGrid1.Columns(1).Text <> "" And Rs_J_Pctzd_Sp.Fields("recordlx") = "规格" Then
Xh = 0
While Rs_J_Pctzd_Sp.Fields("recordlx") <> "品名"
Rs_J_Pctzd_Sp.MovePrevious
Xh = Xh + 1
Wend
If Rs_J_Pctzd_Sp.Fields("recordlx") = "品名" And Not IsNull(Rs_J_Pctzd_Sp.Fields("dj")) Then
cSpdj1 = Rs_J_Pctzd_Sp.Fields("dj")
End If
For I = 1 To Xh
Rs_J_Pctzd_Sp.MoveNext
Next
DataGrid1.Columns(4).Text = Round(DataGrid1.Columns(3).Text * DataGrid1.Columns(1).Text, 2)
If Int(cSpdj1) <> 0 Then
DataGrid1.Columns(4).Text = Round(DataGrid1.Columns(3).Text * DataGrid1.Columns(1).Text, 2) / Int(cSpdj1)
End If
End If
End If
Select Case DataGrid1.Col
Case 3
If Rs_J_Pctzd_Sp.Fields("recordlx") = "品名" Then
Combo3.Width = DataGrid1.Columns(DataGrid1.Col).Width + 30
Combo3.Left = DataGrid1.Left + DataGrid1.Columns(DataGrid1.Col).Left
Combo3.Top = DataGrid1.Top + DataGrid1.Row * (DataGrid1.RowHeight) + 195
Combo3.Visible = True
Combo3.SetFocus
End If
Case Else
Combo3.Visible = False
End Select
End If
End If
End Sub
'If DataGrid1.Enabled = True Then
' If Not Rs_J_Pctzd_Sp.EOF Then
' If DataGrid1.Col = 1 Or DataGrid1.Col = 3 Or DataGrid1.Col = 4 Then
' If DataGrid1.Columns(3).Text <> "" And DataGrid1.Columns(1).Text <> "" Then
' DataGrid1.Columns(4).Text = Round(DataGrid1.Columns(3).Text * DataGrid1.Columns(1).Text, 2)
' End If
' End If
' End If
'End If
Dim Xh As Integer
Dim cSpdj1 As Double
If DataGrid1.Enabled = True Then
If Not Rs_J_Pctzd_Sp.EOF Then
If DataGrid1.Col = 1 Or DataGrid1.Col = 3 Or DataGrid1.Col = 4 Then
If DataGrid1.Columns(3).Text <> "" And DataGrid1.Columns(1).Text <> "" And Rs_J_Pctzd_Sp.Fields("recordlx") = "规格" Then
Xh = 0
While Rs_J_Pctzd_Sp.Fields("recordlx") <> "品名"
Rs_J_Pctzd_Sp.MovePrevious
Xh = Xh + 1
Wend
If Rs_J_Pctzd_Sp.Fields("recordlx") = "品名" And Not IsNull(Rs_J_Pctzd_Sp.Fields("dj")) Then
cSpdj1 = Rs_J_Pctzd_Sp.Fields("dj")
End If
For I = 1 To Xh
Rs_J_Pctzd_Sp.MoveNext
Next
DataGrid1.Columns(4).Text = Round(DataGrid1.Columns(3).Text * DataGrid1.Columns(1).Text, 2)
If Int(cSpdj1) <> 0 Then
DataGrid1.Columns(4).Text = Round(DataGrid1.Columns(3).Text * DataGrid1.Columns(1).Text, 2) / Int(cSpdj1)
End If
End If
End If
Select Case DataGrid1.Col
Case 3
If Rs_J_Pctzd_Sp.Fields("recordlx") = "品名" Then
Combo3.Width = DataGrid1.Columns(DataGrid1.Col).Width + 30
Combo3.Left = DataGrid1.Left + DataGrid1.Columns(DataGrid1.Col).Left
Combo3.Top = DataGrid1.Top + DataGrid1.Row * (DataGrid1.RowHeight) + 195
Combo3.Visible = True
Combo3.SetFocus
End If
Case Else
Combo3.Visible = False
End Select
End If
End If
End Sub
Combo3.Left = DataGrid1.Left + DataGrid1.Columns(DataGrid1.Col).Left
Combo3.Top = DataGrid1.Top + DataGrid1.Row * (DataGrid1.RowHeight) + 195
Combo3.Visible = True
Combo3.SetFocus