|
-
December 1st, 2004, 04:19 AM
#1
urgent! can anybody help me with listview?
i want something like this:
when i click on a listviewitem to select all rows that have same tag property
the example below, it works, apparently , but when i click again on the selected rows,i t will remain only one selected , always.why?
my example is :
in form_load() event....
ListView1.View = View.Details
ListView1.LabelEdit = False
ListView1.Columns.Add("nr", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("account", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("sum", 100, HorizontalAlignment.Right)
Dim lve As New ListViewItem
'*1
lve = ListView1.Items.Add("1")
lve.SubItems.Add("1000")
lve.SubItems.Add("250")
lve.Tag = 1
'*2
lve = ListView1.Items.Add("1")
lve.SubItems.Add("2000")
lve.SubItems.Add("-250")
lve.Tag = 1
'*3
lve = ListView1.Items.Add("2")
lve.SubItems.Add("1010")
lve.SubItems.Add("150")
lve.Tag = 2
'*4
lve = ListView1.Items.Add("2")
lve.SubItems.Add("2010")
lve.SubItems.Add("-150")
lve.Tag = 2
and in listview1_mouseUp() event
Dim el As ListViewItem
If ListView1.SelectedItems.Count > 0 Then
Dim index As Integer = ListView1.SelectedItems(0).Index
Dim ta As Integer = ListView1.SelectedItems(0).Tag
For Each el In ListView1.Items
If el.Tag = ta Then
el.Selected = True
Else
el.Selected = False
End If
Next
End If
note:the listview1,has multiselect=true,hideselection=false,fullrowselect=true
from the design.
-
December 1st, 2004, 04:38 AM
#2
Re: urgent! can anybody help me with listview?
Wrong event - it is fired before new item is selected.
Try to use listview1_clicked() event (or selectedindexchanged event in .NET) instead.
Best regards,
Krzemo.
-
December 2nd, 2004, 03:08 AM
#3
Re: urgent! can anybody help me with listview?
yes but,when you use selected property,in event like selectedindexchanged()
it will go over and over again,will give stackoverflow
in click() i tried,and same result.
-
December 2nd, 2004, 07:34 AM
#4
Re: urgent! can anybody help me with listview?
yes but,when you use selected property,in event like selectedindexchanged()
it will go over and over again,will give stackoverflow
Then block it:
Code:
Dim bInternal as boolean
....
in selectedindexchanged():
if not bInternal then
bInternal =true
... your code
end if
bInternal =false
... or something else like that
Hope it helps.
-
December 9th, 2004, 10:31 AM
#5
Re: urgent! can anybody help me with listview?
first solution was to put in mouse_up() all the selection thing, but after that
i noticed that when it's already selected and i clic again on the selected items, it will highlight only the focused,even if the selecteditems.count>1 .
(same strange thing was ,with that boolean variable solution), so
i put in mouse_down()
for each event a
selecteditems.clear()
and it was well, but i find another faster way.
to play with the colors, to change the backgroundcolor and the forecolor when is one selected,it's another way to select them, it goes faster ,and works well with the keyboard as well(i change the selection of items with keys)
thanks any way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|