问题如下:窗体有一个listview控件,一个imagelist控件,form引导后已经添加了item到listview中,触发itemclick事件,正常,问题就是单击完一个item完成itemclick事件后,为什么那个item会跟随光标移动,而不是恢复到原来的没有选择item的状态?
我有没有表达清楚啊?需要的话,我给代码。

解决方案 »

  1.   

    但这样就看不到imagelist里的图片了
      

  2.   

    CSDN我没什么分  请大家帮帮我
      

  3.   

    listview.imagelist 里的 small 设成 imagelist1
    ListView1.ListItems.Add 时,用 smallicon
      

  4.   

    smallicon还是看不到图像 ,并且存在跟光标移动的问题
      

  5.   

    请把 Begin MSComctlLib.ListView ListView1 和
    Begin MSComctlLib.ImageList ImageList1 下面的code贴下,
    还有
    ListView1.ListItems.Add 
      

  6.   

    Begin MSComctlLib.ListView ListView1 
                Height          =   3945
                Left            =   120
                TabIndex        =   6
                Top             =   3120
                Width           =   2160
                _ExtentX        =   3810
                _ExtentY        =   6959
                LabelWrap       =   -1  'True
                HideSelection   =   -1  'True
                HoverSelection  =   -1  'True
                _Version        =   393217
                Icons           =   "ImageList1"
                SmallIcons      =   "ImageList1"
                ColHdrIcons     =   "ImageList1"
                ForeColor       =   -2147483640
                BackColor       =   16774110
                Appearance      =   1
                NumItems        =   1
                BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
                   Object.Width           =   2540
                EndProperty
             End
          End      Begin MSComctlLib.ImageList ImageList1 
             Left            =   2880
             Top             =   2520
             _ExtentX        =   1005
             _ExtentY        =   1005
             BackColor       =   -2147483643
             ImageWidth      =   32
             ImageHeight     =   32
             MaskColor       =   12632256
             _Version        =   393216
             BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
                NumListImages   =   23
                BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":C44E
                   Key             =   ""
                EndProperty
                BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":C768
                   Key             =   ""
                EndProperty
                BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":D7BA
                   Key             =   ""
                EndProperty
                BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":E80C
                   Key             =   ""
                EndProperty
                BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":F85E
                   Key             =   ""
                EndProperty
                BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":108B0
                   Key             =   ""
                EndProperty
                BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":11902
                   Key             =   ""
                EndProperty
                BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":12954
                   Key             =   ""
                EndProperty
                BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":139A6
                   Key             =   ""
                EndProperty
                BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":149F8
                   Key             =   ""
                EndProperty
                BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":15A4A
                   Key             =   ""
                EndProperty
                BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":16A9C
                   Key             =   ""
                EndProperty
                BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":17AEE
                   Key             =   ""
                EndProperty
                BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":18B40
                   Key             =   ""
                EndProperty
                BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":19B92
                   Key             =   ""
                EndProperty
                BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":1ABE4
                   Key             =   ""
                EndProperty
                BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":1BC36
                   Key             =   ""
                EndProperty
                BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":1CC88
                   Key             =   ""
                EndProperty
                BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":1DCDA
                   Key             =   ""
                EndProperty
                BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":1ED2C
                   Key             =   ""
                EndProperty
                BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":1FD7E
                   Key             =   ""
                EndProperty
                BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":20DD0
                   Key             =   ""
                EndProperty
                BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
                   Picture         =   "MDIForm1.frx":21E22
                   Key             =   ""
                EndProperty
             EndProperty
          End
      

  7.   

    ListView1.ListItems.Add 这一句呢?
      

  8.   

    Private Sub lblMenu_Click(Index As Integer)
      strMenu = lblMenu(Index).Caption
      Dim m As Integer
      For i = 1 To Index
        PicMenu(i).Top = PicMenu(i - 1).Top + PicMenu.item(i - 1).Height
      Next i
      ListView1.Top = PicMenu(i - 1).Top + PicMenu.item(i - 1).Height
      If Index < 7 Then PicMenu(Index + 1).Top = ListView1.Top + ListView1.Height
      For i = Index + 2 To PicMenu.Count - 1
        PicMenu(i).Top = PicMenu.item(i - 1).Top + PicMenu.item(i - 1).Height
      Next i
      Select Case Index
       Case 0
         ListView1.ListItems.Clear
         ListView1.Enabled = True
         For i = 0 To m1.Count - 1
           Key = "【" & m1.item(i).Caption & "】"
           m = i + 1
           Set itmX = ListView1.ListItems.Add(, , Key, m)
        Next i
       Case 1
        ListView1.ListItems.Clear
        ListView1.Enabled = True
        For i = 0 To m2.Count - 1
          Key = "【" & m2.item(i).Caption & "】"
          m = i + m1.Count + 1
          Set itmX = ListView1.ListItems.Add(, , Key, m)
        Next i
       Case 2
        ListView1.ListItems.Clear
        ListView1.Enabled = True
        For i = 0 To m3.Count - 1
          Key = "【" & m3.item(i).Caption & "】"
          m = m1.Count + m2.Count + i + 1
           Set itmX = ListView1.ListItems.Add(, , Key, m)
        Next i
       Case 3
           ListView1.ListItems.Clear
           ListView1.Enabled = True
           For i = 0 To m4.Count - 1
             Key = "【" & m4.item(i).Caption & "】"
             m = m1.Count + m2.Count + m3.Count + i + 1
             Set itmX = ListView1.ListItems.Add(, , Key, m)
           Next i
       Case 4
           ListView1.ListItems.Clear
           ListView1.Enabled = True
           For i = 0 To m5.Count - 1
             Key = "【" & m5.item(i).Caption & "】"
             m = m1.Count + m2.Count + m3.Count + m4.Count + i + 1
             Set itmX = ListView1.ListItems.Add(, , Key, m)
           Next i
       Case 5
           ListView1.ListItems.Clear
           ListView1.Enabled = True
           For i = 0 To m6.Count - 1
             Key = "【" & m6.item(i).Caption & "】"
             m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + i + 1
             Set itmX = ListView1.ListItems.Add(, , Key, m)
           Next i
       Case 6
           ListView1.ListItems.Clear
           ListView1.Enabled = True
           For i = 0 To m7.Count - 1
             Key = "【" & m7.item(i).Caption & "】"
             m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + m6.Count + i + 1
             Set itmX = ListView1.ListItems.Add(, , Key, m)
           Next i
        Case 7
           ListView1.ListItems.Clear
           ListView1.Enabled = True
           For i = 0 To m8.Count - 1
             Key = "【" & m8.item(i).Caption & "】"
             m = m1.Count + m2.Count + m3.Count + m4.Count + m5.Count + m6.Count + m7.Count + i + 1
             Set itmX = ListView1.ListItems.Add(, , Key, m)
             Itemgross = m
           Next i
       End Select
    End Sub
      

  9.   

    ListView1。view = 2,你没改。
      

  10.   

    Set itmX = ListView1.ListItems.Add(, , Key, m) 
    这个m是在icon,里,在前面加个逗号,
      

  11.   

    listView1.view=2这个是能消除光标跟随的问题  可看不到图片啊 
      

  12.   

    Set itmX = ListView1.ListItems.Add(, , Key, , m) 
      

  13.   

    13楼的我试了   item跟随光标  我的itemclick里的代码是form.show 1
      

  14.   

    把form.show 1 改成form.show 0,me也能解决问题  可点击后form需要再点击一下才能用  不点击是灰色的
      

  15.   

    俩个一起,
    view=2 --》item跟随光标
    smallicon = imagelist
    Set itmX = ListView1.ListItems.Add 用最后面的。
      

  16.   

    分不多  谢谢  view=2跟Set itmX = ListView1.ListItems.Add(,,key,m)为什么看不到图标
    但(,,key,,m)能看到图标??
      

  17.   

    我没上过vb的专业的,有些东西我知道怎么做,但理论上讲不清楚,vb就是要多实践