private void Consumption_Load(object sender, EventArgs e) { listgood = new List <Goods>(); DataTable dt = gt.SearchGoods(null); for (int i = 0; i < dt.Rows.Count; i++) { comboBox1.Items.Add(dt.Rows[i]["GoodName"].ToString()); Goods gd = new Goods(); gd.GoodName = dt.Rows[i]["GoodName"].ToString(); gd.GoodPrice = Convert.ToInt32(dt.Rows[i]["GoodPrice"]); listgood.Add(gd); } }
/// <summary> /// 查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { dataGridView1.DataSource = GT.SearchGoods(textBox1.Text.Trim()); }