Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how to get all combobox items in single array........
Posted
Updated 22-Dec-20 5:43am
Comments
Prerak Patel 4-Nov-11 4:22am    
You want to get the list of items in array, or you want to populate items from array?

Array to items
VB
Dim items() as String = new String(){"Typical", "Compact", "Custom"}
ComboBox1.Items.AddRange(installs)


List of items in string array
VB
Dim items() As String = (From item As String In ComboBox1.Items Select item).ToArray
 
Share this answer
 
v3
You can run a loop and iterate over the items in the drop down.
C#
foreach(ListItem l in ddown.Items)
{
    myArr.Add(l);
}


Or you could use LINQ
myarr = down.Items.OfType<listitem>().ToArray();</listitem>
 
Share this answer
 
Comments
Member 14499379 28-Jun-19 13:24pm    
what do you mean by ListItem? It is not showing in C#.net
int i=0;
string[] Recmdes = new string[RecipeName.Items.Count];
foreach (string item in RecipeName.Items)
{
i++;
Recmdes[i] = item;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900