|
-
Nov 16th, 2000, 02:32 PM
#1
Thread Starter
Fanatic Member
I am adding about at least 1500 to 3000 names to a combobox as show below.
Is there a better way of getting the names in the box? As I add more and more names it takes progressively longer to add a name to the list.
Any suggestions would be greatly appreciated.
Code:
For i = 1 to Ubound(username)
Me.cboOldUserName.AddItem (TempUserName)
Me.cboMACLsUserName.AddItem (TempUserName)
Next i
-
Nov 16th, 2000, 02:51 PM
#2
Addicted Member
Without using any APIs or anything like that, one way I have found to speed up things is to make the control invisible.
This may help, I'm not certain in your case.
Code:
Me.cboOldUserName.Visible = False
Me.cboMACLsUserName.Visible = False
For i = 1 to Ubound(username)
Me.cboOldUserName.AddItem (TempUserName)
Me.cboMACLsUserName.AddItem (TempUserName)
Next i
Me.cboOldUserName.Visible = True
Me.cboMACLsUserName.Visible = True
I was doing a standard loop 1 to 3000 and added a string to the two combo boxes, it only took a second or two... perhaps there is something else that is slowing down your loop?
Michael Woolsey
Application/Web Developer
Visual Basic 6.0 SP5
Active Server Pages
Oracle 9i
- I'm going to live forever, or die trying!
-
Nov 16th, 2000, 02:51 PM
#3
Hyperactive Member
This is a CHEAP fix . Set it's .visible propertie to false before you load it then when it's done make it visible again . I noticed this in an app awhile ago . Atleast it was true in my case but I was scrolling the box also . Try it , can't hurt .
[]P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Nov 16th, 2000, 02:56 PM
#4
Fanatic Member
I always use the LockWindowUpdate(xxxxx.hWnd) API to prevent the window from redrawing. After adding the items, simply use LockWindowUpdate(0&) to redraw it's contents.
But also consider that when your list is sorted, this will ALSO take longer than an unsorted list.
Otherwise, it's VERY VERY slow.
A much more faster way to add items, is adding them to strings in memory. After loading you can display them using the Print method on a picturebox.
-
Nov 17th, 2000, 06:53 AM
#5
Thread Starter
Fanatic Member
Thank you all for responses. I will give that a try.
Originally posted by PRIVATE1
This is a CHEAP fix.
Curious, What's the expensive fix?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|