Click here to Skip to main content
15,886,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to populated combo box using Excel column in c# please help...thanks in adv..


What I have tried:

C#
<pre> Workbook workbook = new Workbook();  
            //Load Excel file  
            workbook.LoadFromFile("input.xlsx");  
  
            //Get the first worksheet  
            Worksheet sheet = workbook.Worksheets[0];  
  
            //Bind data in the first Excel column to combo box  
            for (int row = 1; row < sheet.Rows.Count()+1; row++)  
            {  
               string value = sheet.Range[row, 1].Value;  
               comboBox1.Items.Add(value);  
            }  
Posted
Updated 19-Jul-21 22:38pm
Comments
Patrice T 13-Apr-20 4:58am    
what is the problem with this code ?
Sam_gaik 13-Apr-20 5:23am    
It does not work..!
Patrice T 13-Apr-20 5:28am    
This is not informative.
what it does that is not expected, what it don't that is expected?

Just read whole string and create a List<objectthatuwant> with data and fill the list, afther that just give ur combobox a datasource as like:

C#
List<objectthatuwant> list;//fill this list with your data
BindingSource source = new BindingSource();
source.DataSource=list;
comboBox1.DataSource=source;
 
Share this answer
 
v2

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