Hi, Simon
The problem seems to be setting the Sorted property to True. The following
works for me:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
clbWaves.BeginUpdate()
clbWaves.Sorted = False
clbWaves.Items.Clear()
clbWaves.Items.Add("Hello", True)
clbWaves.Sorted = True
clbWaves.EndUpdate()
End Sub
As to >why< Sorted causes problems, that will take some research. I will
let you know what I find out.
Thank you for choosing the MSDN Managed Newsgroups,
John Eikanger
Microsoft Developer Support
This posting is provided “AS IS” with no warranties, and confers no rights.
--------------------
| From: "Simon Jefferies" <
[email protected]>
| Subject: Re: Adding an item to a Checked List Box
| Date: Mon, 19 Apr 2004 10:03:43 +0100
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Thanks for your help,
|
| I've created a new form, and copied the problem code across. I've
stripped
| out all my events etc leaving just a simple button click event to add
items
| to the checked list box. It still doesn't work. I've compared a working
form
| with the unworking one and cant see anything that would cause this
problem.
|
| I've attached the project - two forms inside, Form1 (not working) and
| WorkingForm.
|
| Please let me know if you find anything thats wrong with this form.
|
| Regards
| Simon Jefferies
| Tools Programmer, Headfirst Productions
| mailto:
[email protected]
|
www.headfirst.co.uk www.callofcthulhu.com
| -
| | > Hi, Simon
| >
| > I think it really depends on whether your first priority is getting it
| > working or figuring out what happened. In the former case I would
| > recreate
| > the for in a new project, pasting your code ONLY from the old to the
new.
| > If that works, dive into the form designer code and look for
differences.
| >
| > If you have to know what happened, try pealing the onion. Chop away
what
| > should be irrelevant code and controls is small chunks until things
start
| > working. Put the last piece back and see if it fails. Then go over
the 2
| > files with a fine tooth comb. Something should be obvious.
| >
| > Hope this helps,
| >
| > John Eikanger
| > Microsoft Developer Support
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| > rights.
| > --------------------
| > | From: "Simon Jefferies" <
[email protected]>
| > | Subject: Re: Adding an item to a Checked List Box
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > |
| > | Thanks for your reply,
| > |
| > | When I created a new project it worked! Mmmm...
| > |
| > | I haven't touched the Windows Form designer generated code section.
| > |
| > | Any ideas on what to try next?
| > |
| > | Regards
| > | Simon Jefferies
| > | Tools Programmer, Headfirst Productions
| > | mailto:
[email protected]
| > |
www.headfirst.co.uk www.callofcthulhu.com
| > | -
| > | | > | > Hi, Simon
| > | >
| > | > I can't get it to repro here either.
| > | >
| > | > What happens when you start a new project, add a checked list box &
a
| > | > button, and put your code in the button's click event? If that
works,
| > | > there is probably something wrong in your form or project files.
Have
| > you
| > | > edited the code in the Windows Form Designer generated code section?
| > That
| > | > could be the culpret. If the simple project fails, please zip up
the
| > | > simple project and attach it to a post. That will give us something
| > real
| > | > to play with.
| > | >
| > | > Hope this helps,
| > | >
| > | > John Eikanger
| > | > Microsoft Developer Support
| > | >
| > | > This posting is provided "AS IS" with no warranties, and confers no
| > | > rights.
| > | > --------------------
| > | > | From: "Simon Jefferies" <
[email protected]>
| > | > | Subject: Re: Adding an item to a Checked List Box
| > | > | Date: Thu, 15 Apr 2004 15:57:44 +0100
| > | > | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| > | > |
| > | > | I don't get an exception when I comment out the BeginUpdate,
Clear
| > and
| > | > | EndUpdate.
| > | > |
| > | > | I put back in the Clear() and its still working, so it means
| > | > BeginUpdate()
| > | > | or EndUpdate() or both causes this problem?
| > | > |
| > | > | Yes, I am performing this in the main application thread.
| > | > |
| > | > | Why would this happen?
| > | > |
| > | > | --
| > | > | Regards
| > | > | Simon Jefferies
| > | > | Tools Programmer, Headfirst Productions
| > | > | mailto:
[email protected]
| > | > |
www.headfirst.co.uk www.callofcthulhu.com
| > | > | -
| > message
| > | > | | > | > | > Simon,
| > | > | >
| > | > | > * "Simon Jefferies" <
[email protected]> scripsit:
| > | > | >> clbWaves.BeginUpdate()
| > | > | >> clbWaves.Items.Clear()
| > | > | >> Try
| > | > | >> clbWaves.Items.Add("Hello", True)
| > | > | >> Catch ex As Exception
| > | > | >> End Try
| > | > | >>
| > | > | >> clbWaves.EndUpdate()
| > | > | >>
| > | > | >> The Catch statement is called with the Out of range exception.
| > | > | >
| > | > | > Does the exception occur if you skip the 'Clear',
'BeginUpdate',
| > and
| > | > | > 'EndUpdate'? Are you sure you are performing the operation in
the
| > | > main
| > | > | > GUI thread?
| > | > | >
| > | > | > --
| > | > | > Herfried K. Wagner [MVP]
| > | > | > <URL:
http://dotnet.mvps.org/>
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|