Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Number of selected items in listview wrong


Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2004, 05:20 AM
Ella1969 Ella1969 is offline
Newcomer
 
Join Date: Nov 2003
Posts: 4
Default Number of selected items in listview wrong


Hi guys,

I'm working with a listview and i think it works wrong. If the user clicks on an empty row then will be another (not empty) automatically selected. Does someone observe this strage behaviour? I've tried to found the error and I find out that already

GetSelCountListView = SendMessage(lvw.hwnd, LVM_GETSELECTEDCOUNT, 0, 0)

returns a wrong value.

Sorry for my bad english and thanks for every help.
Reply With Quote
  #2  
Old 12-13-2004, 05:29 AM
robertg's Avatar
robertg robertg is offline
Privileges Suspended
 
Join Date: Dec 2004
Location: Sterling Heights, MI
Posts: 520
Default

Try this:
Code:
Private Sub Command1_Click() Dim i As Integer Dim j As Integer For i = 1 To ListView1.ListItems.Count If (ListView1.ListItems(i).Selected) Then j = j + 1 End If Next MsgBox j End Sub
Reply With Quote
  #3  
Old 12-13-2004, 05:59 AM
Ella1969 Ella1969 is offline
Newcomer
 
Join Date: Nov 2003
Posts: 4
Default

Thank you Robert, but the behaviour is the same. The message box returns 1 if the user clicks on the empty space in the listview and an empty is selected.

I don't know, why this selection happens. It is the last selected item, focus is not relevant. Anyone some idea?
Reply With Quote
  #4  
Old 12-13-2004, 06:06 AM
robertg's Avatar
robertg robertg is offline
Privileges Suspended
 
Join Date: Dec 2004
Location: Sterling Heights, MI
Posts: 520
Default

Put a 'break' at the beginning of the sub, and step through it. Each time through the loop, look at the value to see if it is incrementing, and then somehow getting decremented at the end. Also, if you know, by looking at it, how many items are selected, then that is the number of times it should go through the loop. By 'stepping' through it, you will get a better idea of what is actually happening, and that might lead to why it is happening.
Reply With Quote
  #5  
Old 12-13-2004, 06:17 AM
Ella1969 Ella1969 is offline
Newcomer
 
Join Date: Nov 2003
Posts: 4
Angry

The item which be visualized as selected has .Selected = True. But why? If i deselect it than explicit then has all items .Selected Property = False. But not all the time. Than is suddenly True again. What the hell is this?
Reply With Quote
  #6  
Old 12-13-2004, 09:41 AM
TriggerCell's Avatar
TriggerCell TriggerCell is offline
Junior Contributor
 
Join Date: Sep 2003
Location: Istanbul, TR
Posts: 229
Default

haven't encountered this issue before but i believe listview is a little buggy control since i had had issues with the .Visible property, setting it to False sometimes doesn't have an effect at all. not sure but, this "may" be another bug
__________________
life doesn't mean telling lies | it means enduring what you despise
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->