CheckedListbox - change check event

G

Guest

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 folder. The "check mark" for each item in the
control is determined by the boolean value of a custom property field of the
file. That value is found using microsoft's dsofile.dll class.

That's the background. What's the problem?....there doesn't seem to be any
"checked change" event for the CheckedListBox control. If my user changes the
check mark on one of the items in the CheckedListBox I want to trigger a
procedure to change the value of the file's custom property field

Changing the value is the easy bit, its all written and waiting to
go.....but I can't find a way to trigger the procedure when the check is
changed

Am I missing something ?

Any help would be appreciated

Thanks

Michael Bond
 
A

Al Reid

mabond said:
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 folder. The "check mark" for each item in the
control is determined by the boolean value of a custom property field of the
file. That value is found using microsoft's dsofile.dll class.

That's the background. What's the problem?....there doesn't seem to be any
"checked change" event for the CheckedListBox control. If my user changes the
check mark on one of the items in the CheckedListBox I want to trigger a
procedure to change the value of the file's custom property field

Changing the value is the easy bit, its all written and waiting to
go.....but I can't find a way to trigger the procedure when the check is
changed

Am I missing something ?

Any help would be appreciated

Thanks

Michael Bond

Did you try the ItemCheck event?
"Occurs when the checked state of an item changes"
 
G

Guest

Al

thanks for the reply ....... firstly no, I hadn't tried it (I did say I
thought there would be something I was missing!)

However, having found the event that I need it's now given me an entirely
different problem! Because I re-populate the control with a timer event, the
itemcheck event for every item in the box is being triggered every time the
control is refreshed (logical of course 'cos thats is what I've told it to
do!)

So it's abck to the drawing board and a re-think of my methodolgy for
dealing with this requirement.

Thanks again

Michael Bond


I believe under different circumstances that event would be what I n
 
G

Guest

When changing the checked status, you can "remove" the event handler then
"Add" it back when you are finished. I use the following for a similiar
situation when I am using the treeview control:

RemoveHandler tre_MusicSource.AfterCheck, AddressOf tre_MusicSource_AfterCheck

.....do your thing here

AddHandler tre_MusicSource.AfterCheck, AddressOf tre_MusicSource_AfterCheck
Dennis in Houston

Note: the sub "tre_MusicSource_AfterCheck is the name of the sub that
handles the check event for the treeveiw control named tre_MusicSource.

Hope this helps as I find this technique very useful.
 
G

Guest

Dennis

thanks for the reply .......

In the meantime I had a re-think on my technique.

My CheckedListBox was refreshing with the timer every 1000 ms. This was to
ensure the user (and there are more than one at any given time) would see the
most up to date content of the network folder in question. I've now replaced
the timer event with a filesystem watcher. In that way the CheckedListBox
only refreshes in the event of a change to the folder or any of its contents
and not every second.

Thanks to you and to Al for helping out with suggestions. Much appreciate
the help

Regards

Michael Bond
 
C

Claes Bergefall

Remove your event handler while populating the list and add it back in when
you're done.

Public Sub MyTimerEventHandler(...)
RemoveHandler myListBox.ItemCheck, AddressOf MyItemCheckEventHandler
' Do your stuff
AddHandler myListBox.ItemCheck, AddressOf MyItemCheckEventHandler
End Sub

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top