473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Handling problem with ListView.ItemCheck event

I have a design problem involving a ListView control on a Windows form.
What it boils down to is the following question:

Q: Is there a way to tell the difference between a ListView.ItemCheck
event that has occurred because of a mouse click on a Checkbox, and one
that has occurred because the .Checked property of an item has been
changed programatically?

More details if needed, but if you can answer the above, you'll have
solved the problem! :)

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 22 '05 #1
4 2406
Hi Mike

I use the Infragistics components, and there is a BeforeCheck event.

What I am doing is allowing code to change the check state, but not the user
by clicking an item.

The way I got round the problem you illustrate is to implement the
BeforeCheck handler and always cancel the attempt to check/uncheck the box.
Then, in the code that is allowed to change the state, I remove the handler,
change the state, and then add the handler again. A bit crude, but it works.

Alternatively, set a flag before you make the change in code, and test the
flag in the BeforeCheck event.

One other possibility is that check boxes have an AutoCheck property. If you
set that to false it allows you to control when the check box is checked.

HTH

Charles
"Mike Ruane-Torr" <mike.ruane-torr@USE_EVENS_ixwiflaoyn.net> wrote in
message news:op**************@msnews.microsoft.com...
I have a design problem involving a ListView control on a Windows form.
What it boils down to is the following question:

Q: Is there a way to tell the difference between a ListView.ItemCheck
event that has occurred because of a mouse click on a Checkbox, and one
that has occurred because the .Checked property of an item has been
changed programatically?

More details if needed, but if you can answer the above, you'll have
solved the problem! :)

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Nov 22 '05 #2
Hi Mike

I use the Infragistics components, and there is a BeforeCheck event.

What I am doing is allowing code to change the check state, but not the user
by clicking an item.

The way I got round the problem you illustrate is to implement the
BeforeCheck handler and always cancel the attempt to check/uncheck the box.
Then, in the code that is allowed to change the state, I remove the handler,
change the state, and then add the handler again. A bit crude, but it works.

Alternatively, set a flag before you make the change in code, and test the
flag in the BeforeCheck event.

One other possibility is that check boxes have an AutoCheck property. If you
set that to false it allows you to control when the check box is checked.

HTH

Charles
"Mike Ruane-Torr" <mike.ruane-torr@USE_EVENS_ixwiflaoyn.net> wrote in
message news:op**************@msnews.microsoft.com...
I have a design problem involving a ListView control on a Windows form.
What it boils down to is the following question:

Q: Is there a way to tell the difference between a ListView.ItemCheck
event that has occurred because of a mouse click on a Checkbox, and one
that has occurred because the .Checked property of an item has been
changed programatically?

More details if needed, but if you can answer the above, you'll have
solved the problem! :)

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Nov 22 '05 #3
On Fri, 2 Apr 2004 14:58:01 +0100, Charles Law <bl***@nowhere.com> wrote:
The way I got round the problem you illustrate is to implement the
BeforeCheck handler and always cancel the attempt to check/uncheck the
box.
Then, in the code that is allowed to change the state, I remove the
handler,
change the state, and then add the handler again. A bit crude, but it
works. I considered this kind of approach, but thought that it might not be
thread-safe. Perhaps I should try it.
Alternatively, set a flag before you make the change in code, and test
the
flag in the BeforeCheck event.

I think that would definitely NOT be thread-safe.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 22 '05 #4
On Fri, 2 Apr 2004 14:58:01 +0100, Charles Law <bl***@nowhere.com> wrote:
The way I got round the problem you illustrate is to implement the
BeforeCheck handler and always cancel the attempt to check/uncheck the
box.
Then, in the code that is allowed to change the state, I remove the
handler,
change the state, and then add the handler again. A bit crude, but it
works. I considered this kind of approach, but thought that it might not be
thread-safe. Perhaps I should try it.
Alternatively, set a flag before you make the change in code, and test
the
flag in the BeforeCheck event.

I think that would definitely NOT be thread-safe.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Ruane-Torr | last post by:
I have a design problem involving a ListView control on a Windows form. What it boils down to is the following question: Q: Is there a way to tell the difference between a ListView.ItemCheck...
2
by: Mike Ruane-Torr | last post by:
I have a design problem involving a ListView control on a Windows form. What it boils down to is the following question: Q: Is there a way to tell the difference between a ListView.ItemCheck...
3
by: | last post by:
Hello, I have a ListView control in Details view. When an item is un-checked, I want to change the ForeColor. The only way I have found to do this is to loop through all the items of the...
0
by: Mike Ruane-Torr | last post by:
I have a design problem involving a ListView control on a Windows form. What it boils down to is the following question: Q: Is there a way to tell the difference between a ListView.ItemCheck...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.