Currently, I'm doing this:

Private Sub Populate()
cboCategory.Items.Clear()
cboSubcategory.Items.Clear()
cboFileCategory.Items.Clear()
cboSubcategory.Items.Add("Root")
cboFileCategory.Items.Add("Root")
For Each cCat In Categories
cboCategory.Items.Add(cCat.Name)
cboSubcategory.Items.Add(cCat.Name)
cboFileCategory.Items.Add(cCat.Name)
Next
End Sub

Now it seems like it would be more efficient to add the items to
cboCategory, then use something like the AddRange method like this:
Private Sub Populate()
cboCategory.Items.Clear()
cboSubcategory.Items.Clear()
cboFileCategory.Items.Clear()
cboSubcategory.Items.Add("Root")
For Each cCat In Categories
cboCategory.Items.Add(cCat.Name)
Next

cboSubcategory.Items.AddRange(cboCategory.Items)
cboFileCategory.Items.AddRange(cboSubcategory.Items)
End Sub

Now of course, the above doesn't work; but is there a way to accomplish this?

--
Alex C. Barberi
Chief Executive Officer
VisionForce
http://www.visionforceweb.com

Re: Adding items to a ComboBox by cody

cody
Wed Feb 22 11:10:34 CST 2006

Make a loop adding the names to an Array an after that you can use AddRange.
Adding items to an array is somewhat faster than adding them to a combobox.

alternatively you can use databindung which should even be faster.

"Alex C. Barberi" <AlexCBarberi@discussions.microsoft.com> schrieb im
Newsbeitrag news:47043162-4F2C-43D8-BDEE-34FC2FE48CD8@microsoft.com...
> Currently, I'm doing this:
>
> Private Sub Populate()
> cboCategory.Items.Clear()
> cboSubcategory.Items.Clear()
> cboFileCategory.Items.Clear()
> cboSubcategory.Items.Add("Root")
> cboFileCategory.Items.Add("Root")
> For Each cCat In Categories
> cboCategory.Items.Add(cCat.Name)
> cboSubcategory.Items.Add(cCat.Name)
> cboFileCategory.Items.Add(cCat.Name)
> Next
> End Sub
>
> Now it seems like it would be more efficient to add the items to
> cboCategory, then use something like the AddRange method like this:
> Private Sub Populate()
> cboCategory.Items.Clear()
> cboSubcategory.Items.Clear()
> cboFileCategory.Items.Clear()
> cboSubcategory.Items.Add("Root")
> For Each cCat In Categories
> cboCategory.Items.Add(cCat.Name)
> Next
>
> cboSubcategory.Items.AddRange(cboCategory.Items)
> cboFileCategory.Items.AddRange(cboSubcategory.Items)
> End Sub
>
> Now of course, the above doesn't work; but is there a way to accomplish
> this?
>
> --
> Alex C. Barberi
> Chief Executive Officer
> VisionForce
> http://www.visionforceweb.com
>



Re: Adding items to a ComboBox by AlexCBarberi

AlexCBarberi
Wed Feb 22 11:26:29 CST 2006

Thanks! I don't know why I didn't think of that.

--
Alex C. Barberi
Chief Executive Officer
VisionForce
http://www.visionforceweb.com



"cody" wrote:

> Make a loop adding the names to an Array an after that you can use AddRange.
> Adding items to an array is somewhat faster than adding them to a combobox.
>
> alternatively you can use databindung which should even be faster.
>
> "Alex C. Barberi" <AlexCBarberi@discussions.microsoft.com> schrieb im
> Newsbeitrag news:47043162-4F2C-43D8-BDEE-34FC2FE48CD8@microsoft.com...
> > Currently, I'm doing this:
> >
> > Private Sub Populate()
> > cboCategory.Items.Clear()
> > cboSubcategory.Items.Clear()
> > cboFileCategory.Items.Clear()
> > cboSubcategory.Items.Add("Root")
> > cboFileCategory.Items.Add("Root")
> > For Each cCat In Categories
> > cboCategory.Items.Add(cCat.Name)
> > cboSubcategory.Items.Add(cCat.Name)
> > cboFileCategory.Items.Add(cCat.Name)
> > Next
> > End Sub
> >
> > Now it seems like it would be more efficient to add the items to
> > cboCategory, then use something like the AddRange method like this:
> > Private Sub Populate()
> > cboCategory.Items.Clear()
> > cboSubcategory.Items.Clear()
> > cboFileCategory.Items.Clear()
> > cboSubcategory.Items.Add("Root")
> > For Each cCat In Categories
> > cboCategory.Items.Add(cCat.Name)
> > Next
> >
> > cboSubcategory.Items.AddRange(cboCategory.Items)
> > cboFileCategory.Items.AddRange(cboSubcategory.Items)
> > End Sub
> >
> > Now of course, the above doesn't work; but is there a way to accomplish
> > this?
> >
> > --
> > Alex C. Barberi
> > Chief Executive Officer
> > VisionForce
> > http://www.visionforceweb.com
> >
>
>
>