Esempio n. 1
0
        /// <summary>
        /// 显示数据网格控件
        /// </summary>
        public void ShowDataGird()
        {
            this.dataGridView1.DataSource = null;
            this.dataGridView1.Columns.Clear();

            List <Goods> list = GoodsHelper.FindList(new Goods(), new List <string>());

            dataGridView1.DataSource = list;

            dataGridView1.Columns["name"].HeaderText = "商品名";
            dataGridView1.Columns["type"].HeaderText = "商品类型";
            dataGridView1.Columns["sum"].HeaderText  = "库存数量";

            dataGridView1.Columns["id"].Visible = false;

            DataGridViewButtonColumn col_Btn_alter = new DataGridViewButtonColumn();

            col_Btn_alter.Name       = "colBtn_alter";
            col_Btn_alter.HeaderText = "";
            col_Btn_alter.DefaultCellStyle.NullValue = "修改";
            dataGridView1.Columns.Add(col_Btn_alter);

            DataGridViewButtonColumn col_Btn_Drop = new DataGridViewButtonColumn();

            col_Btn_Drop.Name       = "colBtn_drop";
            col_Btn_Drop.HeaderText = "";
            col_Btn_Drop.DefaultCellStyle.NullValue = "删除";
            dataGridView1.Columns.Add(col_Btn_Drop);
        }