This is a migrated thread and some comments may be shown as answers.

How to Populate (not bind) ComboBox

2 Answers 108 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
El
Top achievements
Rank 1
El asked on 13 Jan 2009, 07:37 PM
Usually i populate the common DropDown list using the following code:

Dim installed_fonts As New InstalledFontCollection 
For Each family In FontFamily.Families 
    DropDownList1.Items.Add(family.Name) 
Next family 

For some reasons i cannot use the same code for RadCombobox.

Can you show me how do i populate it with the currently installed fonts ??

Thanks


2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 14 Jan 2009, 05:54 AM
Hi,

RadComboBox allows to add RadComboBoxItem, but in case of dropdownlist it allows strings and ListItem to be added as dropdownlistitem. So one suggestion is that, create RadComboBoxItem and change the text of that with the font name, then add each items with RadComboBox. Try the following code snippets.

VB:
Dim installed_fonts As New InstalledFontCollection() 
For Each family In installed_fonts.Families 
     Dim item As New RadComboBoxItem() 
     item.Text = family.Name 
     RadComboBox1.Items.Add(item) 
Next 

Thanks,
Shinu.
0
El
Top achievements
Rank 1
answered on 14 Jan 2009, 12:01 PM
Thanks for the reply Shinu. It's much appreciated.
Actually, i already discovered it ... and have done it very similar to your approach.
but, i was wondering if there is another way to avoid the declaring of new item for each font separately?

Thanks once again
El

Tags
ComboBox
Asked by
El
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
El
Top achievements
Rank 1
Share this question
or