listview_MouseUp和listview_DBLClick是不是两个事件冲突,软件调试时没有问题,但是编译之后提示运行时错误,请问高手怎么解决

解决方案 »

  1.   

    两个事件不冲突,
    只是先后问题:
    listview_MouseUp在前
    listview_DBLClick在后,
    如果你的程序有问题.请你仔细检查一下代码.
      

  2.   

    Private Sub ListView2_ColumnClick(Index As Integer, ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    add_temp If Index = 0 Then
          listviewcode = ColumnHeader.Index
          listviewname = labxin.ListView2(0).ColumnHeaders.Item(ColumnHeader.Index).Text
     End If
     If Index = 1 Then
          listviewcode = ColumnHeader.Index + labxin.ListView2(0).ColumnHeaders.Count
          listviewname = labxin.ListView2(1).ColumnHeaders.Item(ColumnHeader.Index).Text
     End If
     If Index = 2 Then
          listviewcode = ColumnHeader.Index + labxin.ListView2(0).ColumnHeaders.Count + labxin.ListView2(1).ColumnHeaders.Count
          listviewname = labxin.ListView2(2).ColumnHeaders.Item(ColumnHeader.Index).Text
     End If
     If Index = 3 Then
          listviewcode = ColumnHeader.Index + labxin.ListView2(0).ColumnHeaders.Count + labxin.ListView2(1).ColumnHeaders.Count + labxin.ListView2(2).ColumnHeaders.Count
          listviewname = labxin.ListView2(3).ColumnHeaders.Item(ColumnHeader.Index).Text
     End If
        
    PopupMenu SX
    End SubPrivate Sub ListView2_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
    For i = 0 To 3
    If Index = i Then
     If labxin.ListView2(i).ListItems.Count = 0 Then
       MsgBox "没有数据,请不要乱点击!", vbInformation, "警告"
       Exit Sub
     End If
    End If
    Next
       If Button = 1 Then
     Dim ctrl As ListItem, ctrl1 As ListItem, ctrl2 As ListItem
     If Index = 0 Then   If labxin.Label1.caption = "可塑性表查询" Or labxin.Label1.caption = "可溶性盐、CEC查询" Or labxin.Label1.caption = "激光粒度表查询" Or labxin.Label1.caption = "化分表查询" Then
        Exit Sub
       End If
      
     'ListView2(0).DropHighlight = ""
      Set ctrl = ListView2(0).ListItems(ListView2(0).SelectedItem.Index)
        ListView2(0).DropHighlight = ctrl
        ListView2(1).ListItems(ListView2(0).SelectedItem.Index).Selected = True
        ListView2(1).SetFocus
        
       If labxin.Label1.caption = "化分表、粒度查询" Then
        Exit Sub
       End If
        
      Set ctrl = ListView2(1).ListItems(ListView2(1).SelectedItem.Index)
        ListView2(1).DropHighlight = ctrl
        ListView2(2).ListItems(ListView2(0).SelectedItem.Index).Selected = True
        ListView2(2).SetFocus
      Set ctrl = ListView2(2).ListItems(ListView2(2).SelectedItem.Index)
        ListView2(2).DropHighlight = ctrl
        ListView2(3).ListItems(ListView2(0).SelectedItem.Index).Selected = True
        ListView2(3).SetFocus
      Set ctrl = ListView2(3).ListItems(ListView2(3).SelectedItem.Index)
        ListView2(3).DropHighlight = ctrl
        ListView2(0).ListItems(ListView2(0).SelectedItem.Index).Selected = True
        ListView2(0).SetFocus
     End If If Index = 1 Then
     'ListView2(1).DropHighlight = ""
      Set ctrl = ListView2(1).ListItems(ListView2(1).SelectedItem.Index)
        ListView2(1).DropHighlight = ctrl
        
      If labxin.Label1.caption <> "化分表、粒度查询" Then
        ListView2(2).ListItems(ListView2(1).SelectedItem.Index).Selected = True
        ListView2(2).SetFocus
      Set ctrl = ListView2(2).ListItems(ListView2(2).SelectedItem.Index)
        ListView2(2).DropHighlight = ctrl
        ListView2(3).ListItems(ListView2(1).SelectedItem.Index).Selected = True
        ListView2(3).SetFocus
      Set ctrl = ListView2(3).ListItems(ListView2(3).SelectedItem.Index)
        ListView2(3).DropHighlight = ctrl
      End If
      
        ListView2(0).ListItems(ListView2(1).SelectedItem.Index).Selected = True
        ListView2(0).SetFocus
      Set ctrl = ListView2(0).ListItems(ListView2(0).SelectedItem.Index)
        ListView2(0).DropHighlight = ctrl
        ListView2(1).ListItems(ListView2(1).SelectedItem.Index).Selected = True
        ListView2(1).SetFocus
     End If If Index = 2 Then
     'ListView2(2).DropHighlight = ""
      Set ctrl = ListView2(2).ListItems(ListView2(2).SelectedItem.Index)
        ListView2(2).DropHighlight = ctrl
        ListView2(3).ListItems(ListView2(2).SelectedItem.Index).Selected = True
        ListView2(3).SetFocus
      Set ctrl = ListView2(3).ListItems(ListView2(3).SelectedItem.Index)
        ListView2(3).DropHighlight = ctrl
        ListView2(0).ListItems(ListView2(2).SelectedItem.Index).Selected = True
        ListView2(0).SetFocus
      Set ctrl = ListView2(0).ListItems(ListView2(0).SelectedItem.Index)
        ListView2(0).DropHighlight = ctrl
        ListView2(1).ListItems(ListView2(2).SelectedItem.Index).Selected = True
        ListView2(1).SetFocus
      Set ctrl = ListView2(1).ListItems(ListView2(1).SelectedItem.Index)
        ListView2(1).DropHighlight = ctrl
        ListView2(2).ListItems(ListView2(2).SelectedItem.Index).Selected = True
        ListView2(2).SetFocus
     End If If Index = 3 Then
     'ListView2(2).DropHighlight = ""
      Set ctrl = ListView2(3).ListItems(ListView2(3).SelectedItem.Index)
        ListView2(3).DropHighlight = ctrl
        ListView2(0).ListItems(ListView2(3).SelectedItem.Index).Selected = True
        ListView2(0).SetFocus
      Set ctrl = ListView2(0).ListItems(ListView2(0).SelectedItem.Index)
        ListView2(0).DropHighlight = ctrl
        ListView2(1).ListItems(ListView2(3).SelectedItem.Index).Selected = True
        ListView2(1).SetFocus
      Set ctrl = ListView2(1).ListItems(ListView2(1).SelectedItem.Index)
        ListView2(1).DropHighlight = ctrl
        ListView2(2).ListItems(ListView2(3).SelectedItem.Index).Selected = True
        ListView2(2).SetFocus
      Set ctrl = ListView2(2).ListItems(ListView2(2).SelectedItem.Index)
        ListView2(2).DropHighlight = ctrl
        ListView2(3).ListItems(ListView2(3).SelectedItem.Index).Selected = True
        ListView2(3).SetFocus
     End If
    End If '   按下鼠标右键。
    If Button = 2 Then   Form10.Show vbModal
    End If
    End Sub
    根本看不出错,把其中一个过程去掉,就没有问题
      

  3.   

    Private Sub ListView1_DblClick()
    If ListView1.ListItems.Count > 0 Then
     For i = 1 To ListView1.ListItems.Count
       If ListView1.ListItems.Item(i).Selected = True Then
       cmtc.Label1.caption = ListView1.ListItems.Item(i).SubItems(1)
        rs1.Open "select * from Sys_V_Popedom3 where users='" & Trim(Form2.Label1.caption) & "'", conn, 1, 1
            For k = 1 To rs1.RecordCount
             T = Int(rs1("functioncode"))  't为匹配记录的记录号            cmtc.XPButton1(T - 133).Enabled = True
     
                  rs1.MoveNext
            Next
       End If
     Next
    End If
    rs1.Close
    cmtc.Show vbModal
    End Sub
      

  4.   

    代码太多了! 好好跟踪一下,看看err对象信息变化
      

  5.   

    http://topic.csdn.net/u/20080717/16/e8dab1ef-8c51-491c-ba44-37e9116abda4.html我是来接分的.你的问题已有上面那个贴子中,我帮你解决.