By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,382 Members | 2,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,382 IT Pros & Developers. It's quick & easy.

Handling ListView Check Changes

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.