Read/Bind Notepad Data in to ComboBox using C#

Introduction
This Blog Describes, Read Notepad Data / Bind Notepad data in to ComboBox C# windows Application
 
Step 1
 
First of all create a TEXT file. Like this
 
 
 
Step 2
 
Now Create a New Windows Base Application in Visual Studio
 
File --> New --> Project --> Windows Forms Application 
 
Create a Design Form  Like this:
 
 
 
Step 3
 
Now write the code:
  1. using System.IO;  
  2. namespace Read_notepaddata  
  3. {  
  4.     public partial class Form1: Form  
  5.     {  
  6.         public Form1()  
  7.         {  
  8.             InitializeComponent();  
  9.         }  
  10.         private void Form1_Load(object sender, EventArgs e)  
  11.         {  
  12.             bind();  
  13.         }  
  14.         public void bind()  
  15.         {  
  16.             String path = Application.StartupPath + "\\data.txt";  
  17.             System.IO.StreamReader sr = new System.IO.StreamReader(path);  
  18.             string[] allLine = File.ReadAllLines(path);  
  19.             for (int i = 0; i <= allLine.Length - 1; i++)  
  20.             {  
  21.                 if (allLine[i] == null)  
  22.                 {  
  23.                     break;  
  24.                 }   
  25.                 else  
  26.                 {  
  27.                     string[] item = allLine[i].Split(new char[]   
  28.                     {  
  29.                         '\t'  
  30.                     });  
  31.                     comboBox1.Items.Add(item[0]);  
  32.                     comboBox2.Items.Add(item[1]);  
  33.                 }  
  34.             }  
  35.         }  
  36.     }  
  37. }  
Step 4
 
Now Run Application
 
Output Look like this:
 
 
 
 
Thanks : 
 
If you have any query regarding this feel free to comment me.