473,327 Members | 1,952 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,327 software developers and data experts.

Handling ListView Check Changes

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
ListView in its Click, DoubleClick, and KeyPress events using the sub below
.. However, the ListView can potentially hold hundreds of items, so this
would be quite slow.

Is there a better way to handle when an item is checked/un-checked?

Thank you,

Eric

\\\
Private Sub HandleCheckChange()
Dim item As ListViewItem
For Each item In lvwDirectories.Items
If item.Checked Then
item.ForeColor = SystemColors.WindowText
Else
item.ForeColor = SystemColors.GrayText
End If
Next
End Sub
///
Nov 21 '05 #1
3 3862
What about ListView.ItemCheck event. Didn't it do the trick for you?

--
HTH
Stoitcho Goutsev (100) [C# MVP]
<an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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 ListView in its Click, DoubleClick, and KeyPress events using the sub below . However, the ListView can potentially hold hundreds of items, so this
would be quite slow.

Is there a better way to handle when an item is checked/un-checked?

Thank you,

Eric

\\\
Private Sub HandleCheckChange()
Dim item As ListViewItem
For Each item In lvwDirectories.Items
If item.Checked Then
item.ForeColor = SystemColors.WindowText
Else
item.ForeColor = SystemColors.GrayText
End If
Next
End Sub
///

Nov 21 '05 #2
Oh, brother. I didn't even see the ItemCheck event. Thank you for your
help, Stoitcho.

Please accept my apologies for my ignorance. ;-)

Eric
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
What about ListView.ItemCheck event. Didn't it do the trick for you?

--
HTH
Stoitcho Goutsev (100) [C# MVP]
<an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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
ListView in its Click, DoubleClick, and KeyPress events using the sub

below
. However, the ListView can potentially hold hundreds of items, so this
would be quite slow.

Is there a better way to handle when an item is checked/un-checked?

Thank you,

Eric

\\\
Private Sub HandleCheckChange()
Dim item As ListViewItem
For Each item In lvwDirectories.Items
If item.Checked Then
item.ForeColor = SystemColors.WindowText
Else
item.ForeColor = SystemColors.GrayText
End If
Next
End Sub
///


Nov 21 '05 #3
Use ListView.ItemCheck event

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
<an*******@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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 ListView in its Click, DoubleClick, and KeyPress events using the sub below . However, the ListView can potentially hold hundreds of items, so this
would be quite slow.

Is there a better way to handle when an item is checked/un-checked?

Thank you,

Eric

\\\
Private Sub HandleCheckChange()
Dim item As ListViewItem
For Each item In lvwDirectories.Items
If item.Checked Then
item.ForeColor = SystemColors.WindowText
Else
item.ForeColor = SystemColors.GrayText
End If
Next
End Sub
///

Nov 21 '05 #4

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: Aaron Queenan | last post by:
Is there any way to know whether the OnItemCheck is being called in response to a user action (mouse or keyboard) as opposed to the form loading? I have a class which derives from...
1
by: Curious | last post by:
Hi, I have a listview having 4 columns, where the first column holds data that is unique. I need to update through the listview by searching on the unique field and make the required changes. ...
6
by: Marc Robitaille | last post by:
Hello, I have created a new ListView control that inherits from ListView control. In the WndProc override subroutine, I have been able to find and use those constants : Private Const...
6
by: Josef Brunner | last post by:
Hi, I have a problem using two ListView controls on one and the same form: Problem: The second ListView is never focused. No matter where I "click" non of the items within the ListView is...
3
by: Martin Panggabean | last post by:
Hello All, I've kind a logic problem ... I want to fill the listView control in VB.NET with data in my mySql table using Datareader object component. But It seems that the way of how listView...
2
by: a | last post by:
Hi I have a 3-column listview. It has to return the value of the cell when the user click the listview. The SelectedIndexChanged event and ItemSelectionChanged Event only return the row...
3
by: a | last post by:
Hi, I have a 3-column listview. It has to return the value of the cell when the user click the listview. The SelectedIndexChanged event and ItemSelectionChanged Event only return the row...
2
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.