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

CheckedListBox Questoin

I am trying to capture when an item in the CheckedListBox occurs.

I am using the event:
CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox.ItemCheck

However, this fires before the item is actually checked. So to get over this
problem I tried:

If e.CurrentValue = CheckState.Unchecked Then

e.NewValue = CheckState.Checked

Else

e.NewValue = CheckState.UnChecked

End If

However, setting the e.NewValue doesn't actually seem to change the checked
state (I'm not really sure what it does do!)

I then tried:

If e.CurrentValue = CheckState.Unchecked Then

CheckedListBox.Checked(e.Index,True)

Else

CheckedListBox.SetItemChecked(e.Index, False)

End If

However, this obviously then fires the event again and the who thing goes
into loop.

Does anyone know a way round this?

-Jerry
Nov 21 '05 #1
3 6187
The ItemCheckEventArgs contains both the 'before' and 'after' states of the
CheckBox. You do not need to set the state of the CheckBox.

If e.NewValue = CheckState.Checked
' The new CheckState is Checked - add code to react.
Else
' The new CheckState is Unchecked - add code to react.
End If
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Jerry Spence1" <je**********@somewhere.com> wrote in message
news:41***********************@ptn-nntp-reader04.plus.net...
I am trying to capture when an item in the CheckedListBox occurs.

I am using the event:
CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox.ItemCheck

However, this fires before the item is actually checked. So to get over
this
problem I tried:

If e.CurrentValue = CheckState.Unchecked Then

e.NewValue = CheckState.Checked

Else

e.NewValue = CheckState.UnChecked

End If

However, setting the e.NewValue doesn't actually seem to change the
checked
state (I'm not really sure what it does do!)

I then tried:

If e.CurrentValue = CheckState.Unchecked Then

CheckedListBox.Checked(e.Index,True)

Else

CheckedListBox.SetItemChecked(e.Index, False)

End If

However, this obviously then fires the event again and the who thing goes
into loop.

Does anyone know a way round this?

-Jerry

Nov 21 '05 #2
Say it is in the Unckecked state. You then click on it to put it into the
checked state, and the event is fired. As far the as the event is concerned,
it is still unckecked. It doesn't visibly become checked until after the
event has completed.

- Jerry

"Mike McIntyre" <mi****@dotnetshowandtell.com> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
The ItemCheckEventArgs contains both the 'before' and 'after' states of the CheckBox. You do not need to set the state of the CheckBox.

If e.NewValue = CheckState.Checked
' The new CheckState is Checked - add code to react.
Else
' The new CheckState is Unchecked - add code to react.
End If
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Jerry Spence1" <je**********@somewhere.com> wrote in message
news:41***********************@ptn-nntp-reader04.plus.net...
I am trying to capture when an item in the CheckedListBox occurs.

I am using the event:
CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox.ItemCheck
However, this fires before the item is actually checked. So to get over
this
problem I tried:

If e.CurrentValue = CheckState.Unchecked Then

e.NewValue = CheckState.Checked

Else

e.NewValue = CheckState.UnChecked

End If

However, setting the e.NewValue doesn't actually seem to change the
checked
state (I'm not really sure what it does do!)

I then tried:

If e.CurrentValue = CheckState.Unchecked Then

CheckedListBox.Checked(e.Index,True)

Else

CheckedListBox.SetItemChecked(e.Index, False)

End If

However, this obviously then fires the event again and the who thing goes into loop.

Does anyone know a way round this?

-Jerry


Nov 21 '05 #3
Say it is in the Unckecked state. You then click on it to put it into the
checked state, and the event is fired. As far the as the event is concerned,
it is still unckecked. It doesn't visibly become checked until after the
event has completed.

- Jerry

"Mike McIntyre" <mi****@dotnetshowandtell.com> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
The ItemCheckEventArgs contains both the 'before' and 'after' states of the CheckBox. You do not need to set the state of the CheckBox.

If e.NewValue = CheckState.Checked
' The new CheckState is Checked - add code to react.
Else
' The new CheckState is Unchecked - add code to react.
End If
--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com

"Jerry Spence1" <je**********@somewhere.com> wrote in message
news:41***********************@ptn-nntp-reader04.plus.net...
I am trying to capture when an item in the CheckedListBox occurs.

I am using the event:
CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox.ItemCheck
However, this fires before the item is actually checked. So to get over
this
problem I tried:

If e.CurrentValue = CheckState.Unchecked Then

e.NewValue = CheckState.Checked

Else

e.NewValue = CheckState.UnChecked

End If

However, setting the e.NewValue doesn't actually seem to change the
checked
state (I'm not really sure what it does do!)

I then tried:

If e.CurrentValue = CheckState.Unchecked Then

CheckedListBox.Checked(e.Index,True)

Else

CheckedListBox.SetItemChecked(e.Index, False)

End If

However, this obviously then fires the event again and the who thing goes into loop.

Does anyone know a way round this?

-Jerry


Nov 21 '05 #4

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

Similar topics

0
by: Matt C. | last post by:
Does the CheckedListBox support DisplayMember/ValueMember? I have been trying to use these properties with the CheckedListBox and they are not working. I see from Google that databinding is not...
4
by: Reza | last post by:
Hi, I want to check one of the memebrs of a checkedListbox based on its value. I 'm getting a number(say 1355) from another control and based on that number I want to check an item which its...
1
by: xiuyu_0129 | last post by:
Hi All, How do I store a string value for an item in a CheckedListBox in Windows Form? For a web based application, CheckBoxList allowed us to store 2 string values for the item in it. How do...
4
by: Matthew | last post by:
Hi, I am using a checkedlistbox on a windows form and binding it to a collection of classes. clbAliases is the checkedlistbox control selectedplace is a class with property placealiases.This...
8
by: Derek Martin | last post by:
Here is some code that I need help with please: Dim result As New ArrayList Try For i = 0 To objecttest1.PersonList.person_returnnumber - 1 result =...
2
by: Manuel Canas | last post by:
Hi there, I'm having this dilema with a checkedlistbox. I have an array of items in there, what I want to accomplish is the following; The user could check all the items in the...
0
by: Terry Olsen | last post by:
Dim dirs() as string = Directory.GetDirectories(MyPath) CheckedListBox.DataSource = dirs CheckedListBox.Update For I as Integer = 0 To CheckedListBox.Items.Count - 1...
5
by: mabond | last post by:
Hi Can't believe I've not been able to find the answer to this in the on-line help. I have a CheckedListBox which, via a timer control, is populated with the names of files in a network...
6
by: Steve Teeples | last post by:
Can someone show me an example of how to place a "CheckedListBox" property within a PropertyGrid? -- ----------- Thanks, Steve
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.