473,503 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2430
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
410
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
460
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
3868
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
324
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
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.