16,016,489 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 10190163 (Top 14 by date)
Member 10190163
30-Jan-14 8:46am
View
I have now shown more code.
Member 10190163
30-Jan-14 8:46am
View
I have now shown more code.
Member 10190163
6-Sep-13 9:48am
View
OK I have fixed it now, it was because I do a check to see if the thread is being aborted before I add or remove a item from the listbox, but I wasn't doing this check before adding or removing an item from the collection. It works now.
Thanks for your help on this issue though.
Member 10190163
6-Sep-13 9:12am
View
I put your solution with the listbox_remove_0 into a vb project and it works, however I am still having sync issues when I implement it into my other code. One of those issues was because I cleared the listbox with listbox1.items.clear(), but I have fixed this now by clearing the collection with colColors.Clear(). But I still have other problems, because it is still getting out of sync.
Also I have tried using a listview but it does not accomplish what I am trying to achieve do to columns.
Member 10190163
5-Sep-13 11:15am
View
Ow sorry, I didn't see this reply before. I will have a another look at solution 1.
Member 10190163
5-Sep-13 11:13am
View
Alright thanks,
I have uped the array to 0 to 550, since that is the maximum value
and I have fixed it now with
For counter = 0 To 549
arrColors(counter) = arrColors(counter + 1)
Next
just before the: Me.ListBox1.Items.Remove(listbox_text(0))
line
I haven't used a collection though.
Member 10190163
5-Sep-13 10:23am
View
Your right its not to do with timing, the problem is that later on in my code I limit the number of listbox entries with this line: Me.ListBox1.Items.Remove(listbox_text(0)) ' take off the top list box entry
and that will mean the ListBox1_DrawItem sub will be called but a new item is not being added to it, so I think that's why it messes up.
Member 10190163
5-Sep-13 9:47am
View
That's quite an obvious solution when you look at the error message, I should have been able to do that. Thanks for the code, you have been a grate help. I have tested this now on my system and it works well. I am having a problem implementing it into my other code that I was working with as the blue and black messages seem out of sync, this is probably an issue with timing. But as that is a separate issue it will probably be best if I open that as a new question, so thanks for your help you have solved my issue. Well my first issue anyway.
Member 10190163
4-Sep-13 11:45am
View
I am using Windows 7 and Microsoft Visual Basic 2010 Express. I have created a new project and tried to apply your code to this. I have a problem with the line:
e.Graphics.DrawString(ListBox1.Items(e.Index).ToString(), e.Font, arrColors(e.Index), e.Bounds, StringFormat.GenericDefault)
It causes an exception when press run and I can not continue with the program because it brings up a dialog box that lets me brake or continue and when I continue the debugger stops. The dialog box messages is as follows: An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: InvalidArgument=Value of '-1' is not valid for 'index'.
Member 10190163
4-Sep-13 4:56am
View
Also if you are going to test it, you need to remember to change the draw mode property on the listbox.
Member 10190163
4-Sep-13 4:55am
View
Deleted
Also if you are going to test it, you need to remember to change the draw mode property on the listbox.
Member 10190163
4-Sep-13 4:53am
View
I have also tied it with this line: e.Graphics.DrawString(ListBox1.Items.Item(list_num).ToString(), e.Font, myBrush, e.Bounds, StringFormat.GenericDefault)
just in-case this fixes the problem of it being added only to the first item and cleared, but again I had the same problem.
Member 10190163
4-Sep-13 4:51am
View
Thanks for the suggestion, but unfortunately it did not work.
I got an exception every time something was added: A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Also I saw some black and blue items being added, but the problem was it only added them to the first item then they were cleared.
Member 10190163
3-Sep-13 10:30am
View
Because I was under the impression that the refresh would force the listbox to be re-drawn, meaning the ListBox1_DrawItem sub would be called. Is this not the case?
Show More