title: populating the combox and displaying the value in the combobox
body: <p>populating the combox and displaying the value in the combobox
  for eg. if I choose name in the combobox the corresponding ID should display in the text box . Do anybody know? I am learning c#. I tried it can anybody examine the following code.using System;</p>
  
  <p>I wanted to create a array of store the value and then write it out in the text box. can anybody help</p>
  
  <pre><code>using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using System.Data.OleDb;
  namespace DBExample
  {
      public partial class Form1 : Form
      {
          private OleDbConnection dbConn; // Connectionn object
          private OleDbCommand dbCmd; // Command object
          private OleDbDataReader dbReader;// Data Reader object
          private Member aMember;
          private string sConnection;
          // private TextBox tb1;
          // private TextBox tb2;
          private string sql;
          public Form1()
          {
              InitializeComponent();
          }
          private void Form1_Load(object sender, EventArgs e)
          {
              try
              {
                  // Construct an object of the OleDbConnection 
                  // class to store the connection string 
                  // representing the type of data provider 
                  // (database) and the source (actual db)
                  sConnection =
                          "Provider=Microsoft.Jet.OLEDB.4.0;" +
                          "Data Source=c:member.mdb";
                  dbConn = new OleDbConnection(sConnection);
                  dbConn.Open();
                  // Construct an object of the OleDbCommand 
                  // class to hold the SQL query. Tie the 
                  // OleDbCommand object to the OleDbConnection
                  // object
                  sql = "Select * From memberTable Order " +
                          "By LastName , FirstName ";
                  dbCmd = new OleDbCommand();
                  dbCmd.CommandText = sql;
                  dbCmd.Connection = dbConn;
                  // Create a dbReader object 
                  dbReader = dbCmd.ExecuteReader();
                  while (dbReader.Read())
                  {
                      aMember = new Member
                                  (dbReader["FirstName"].ToString(),
                                   dbReader["LastName"].ToString(),
                                   dbReader["StudentId"].ToString(),
                                   dbReader["PhoneNumber"].ToString());
                      // tb1.Text = dbReader["FirstName"].ToString();
                      // tb2.Text = dbReader["LastName"].ToString();
                      // tb1.Text = aMember.X().ToString();
                      //tb2.Text = aMember.Y(aMember.ID).ToString(); 
                      BindingList&lt;Member&gt; comboBoxList = new BindingList&lt;Member&gt;();
  
                      comboBox1.DataSource = comboBoxList; 
                      comboBox1.DisplayMember = "FirstName"; 
                      comboBox1.ValueMember = "ID";
                      // this.comboBox1.Items.Add("aMember.FirstName.ToString()");
                      // this.listBox1.Items.Add(aMember.ToString());
                      // MessageBox.Show(aMember.ToString());
                      // Console.WriteLine(aMember.ToString());
                  }
                  dbReader.Close();
                  dbConn.Close();
              }
              catch (System.Exception exc)
              {
                  MessageBox.Show("show" + exc);
              }
          }
          private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
          {
              textBox2.Text = comboBox1.SelectedValue.ToString();
              this.textBox1.Text = comboBox1.SelectedItem.ToString();
          }
  
  
          private void DbGUI_Load(object sender, EventArgs e)
          {
          }
  
  
  
          private void textBox2_TextChanged(object sender, EventArgs e)
          {
  
          }
          private void textBox1_TextChanged(object sender, EventArgs e)
          {
          }
      }
  
  }
  </code></pre>