Re: listview line selection
If you're using Report View for Listview control then you need to set few other properties to make visual work but in a nutshell all you need is to select ListItem.
Try sample below:
Code:
Option Explicit
Private Sub Form_Load()
With ListView1
.FullRowSelect = True
.HideSelection = False
.View = lvwReport
.ColumnHeaders.Add , , "Col 1"
.ColumnHeaders.Add , , "Col 2"
.ColumnHeaders.Add , , "Col 3"
Dim i As Integer
For i = 1 To 5
.ListItems.Add , , "Item " & i
Next i
End With
End Sub
Private Sub Command1_Click()
ListView1.ListItems(3).Selected = True
End Sub
Re: listview line selection
Btw, instead of Selected property you may also ustilize Listview1.Checkboxes - if set to True a checkbox will appear next to the item on each row.
To check/uncheck items programmatica lly you will need to use Checked property:
Code:
ListView1.ListItems(3).Checked = True
or toggle the value when item is clicked:
Code:
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Item.Checked = Not Item.Checked
End Sub
Re: listview line selection
Ok, i ve got the picture...
so what about my 1st probs, bro rhino ?
i use this code but it hang my VB6
Private Sub Command1_Click()
Dim A As Integer
For A = 1 To 20 ' sent 20 items to list2
List1.ListIndex = A
List2.AddItem List1.Text
Next
pause 0.5
if list1.listindex < list1.listcount
doevents
Dim B As Integer
For B = 1 To 20 'sent other 20 items
List1.ListIndex = B
List2.AddItem List1.Text
Next
do until list1.listindex = list1.listcount
loop
end if
end sub
by the way...thanks for the reply...
my 2nd probs is solved...
thanks bro rhino...
Re: listview line selection
Quote:
Originally Posted by
baru_belajar
1. assume i have 255 items in listbox1 and i wanna move 20 items in to
Sample below will "move" last 20 items from list1 to list2 every 1 second until list1 is empty:
Code:
Option Explicit
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 255
List1.AddItem "Item " & i
Next i
Timer1.Enabled = False
Timer1.Interval = 1000 '1 second
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
Dim sItem As String
For i = List1.ListCount - 1 To List1.ListCount - 20 Step -1
If i < 0 Then Exit For
sItem = List1.List(i)
List2.AddItem sItem, 0
List1.RemoveItem (i)
Next i
Timer1.Enabled = CBool(List1.ListCount)
End Sub
If you want to move first items instead then you need to modify loop a bit (timer1_timer procedure).