コード例 #1
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (cb_MianLiao.SelectedValue != "")
         {
             List <PeiSe> list = cal.selectPeise(cb_MianLiao.Text);
             DataTable    dt   = new DataTable();
             dateTimePicker1.Value = Convert.ToDateTime(list[0].Date);
             for (int i = 0; i < dataGridView1.Columns.Count; i++)
             {
                 dt.Columns.Add(dataGridView1.Columns[i].HeaderCell.Value.ToString(), typeof(String));
             }
             foreach (PeiSe s in list)
             {
                 dt.Rows.Add(s.PingMing, s.HuoHao, s.GuiGe, s.C61601C1, s.C61602C1, s.C61603C1, s.C61605C1, s.C61606C1, s.C61607C1, s.C61609C1, s.C61611C1, s.C61618C1, s.C61624C1, s.C61627C1, s.C61631C1, s.C61632C1, s.C61633C1, s.C61634C1, s.MianLiaoYanSe, s.Id, s.Fabrics, s.Date);
             }
             dataGridView1.DataSource = dt;
         }
     }
     catch (Exception ex)
     {
         //throw ex;
         MessageBox.Show(ex.Message);
     }
 }