Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / November 2003

Tip: Looking for answers? Try searching our database.

listbox/listview - content drawing problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AlexS - 27 Oct 2003 23:52 GMT
Don't know if this is known or not - I can't find anything describing my
issue.

I fill standard listbox in form Load event handler using loop with
lb.Items.Add(someString) inside BeginUpdate/EndUpdate - exactly as MS
prescribes in MSDN samples. Except that immediately after BeginUpdate I
issue listbox.Items.Clear(); Then follows the adding loop.

Problem is that sometimes listbox is displayed as empty one - no entries -
after addition of 1 or more entries in this loop. Problem happens
irregularly. Usually in 1 case from around 100.

I start to wonder if this is related to Load event and possibly sequencing
of internal messages in 1.1. Anybody has any clue what could be the reason?

I tried to use listbox.Invalidate() and listbox.Update() after final
EndUpdate - however found out that this doesn't exclude my problem
completely. Today once again I got empty listbox on screen after adding 1
entry. When I intercept loop in debugger usually everything is displayed Ok.
The only thing which I was able to remark so far is that usually this
problem happens when number of added entries is less than number of entries,
which fit in listbox page. E.g. if listbox is able to show 20 entries I can
expect this problem when I add less than 20 entries in form.Load event
handler. Similar with Listview control.

Thanks!
Alex
jb huber - 05 Nov 2003 17:37 GMT
I had the same problem. To solve it without loosing speed, instead of
adding directly the item in the listbox, I add it to an arrayList. Then,
I make a listBox.AddRange(list.ToArray()). The speed is conserved and
this works...
Why does it not work with BeginUpdate() ? No idea...

JB

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.