Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

checked listview bug ???

24 views
Skip to first unread message

Tariq Ahmad

unread,
Nov 25, 2002, 12:15:10 PM11/25/02
to
hi,

i have a listview that displays checkboxes.
FullRowSelect is set to true and HideSelection is false.

i only want to allow a maximum of 3 checkboxes
to be checked.

i have some code in the _ItemCheck event that
counts the number of items already checked and if this
number =3 then displays an error message and
executes "e.NewValue = CheckState.Unchecked".

now, suppose i have 3 checkboxes checked.

if i select a row in the listview so that the whole row is highlighted
and click the checkbox my code in _ItemCheck is exected but the
checkbox still gets checked!

if i click another checkbox (but dont select the row first) then
my code in _ItemCheck is exected but the checkbox does not gets checked.

is this a bug? or is my understanding incorrect?

thnx.

t.

ps. i can post some sample code if this will help.


Lion Shi

unread,
Nov 28, 2002, 8:30:02 AM11/28/02
to
Hello Tariq,

That is known issue of the ListView control. It is because if multiple
items were selected, we were firing onItemCheck for each item. But, since
we were creating a temp variable for ItemCheckEventArgs inside the foreach
loop, any change to this variable made by the onItemCheck event handler
were being discarded. So, when the handler specifies

e.NewValue = CheckState.Unchecked

This is not respected.

To workaround it, you can subclass ListView and override OnItemCheck to do
what you want.

I hope this information is helpful.

Best regards,

Lion Shi [MS]
MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
From: "Tariq Ahmad" <tariq...@hotmail.com>
Subject: checked listview bug ???
Date: Mon, 25 Nov 2002 17:15:10 -0000
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <OKNf2YKlCHA.2856@tkmsftngp09>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 217.33.218.163
Path: cpmsftngxa08!tkmsftngp01!tkmsftngp09
Xref: cpmsftngxa08 microsoft.public.dotnet.languages.vb:77314
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

0 new messages