private void InitControls() { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns[0].Width = 250; this.dataGridView1.Columns[1].Width = 150; this.dataGridView1.Columns[2].Width = 80; this.dataGridView1.Columns[3].Width = 80; this.dataGridView1.Columns[4].Width = 80; this.dataGridView1.Columns[5].Width = 80; this.dataGridView1.Columns[6].Width = 80; this.dataGridView1.Columns[7].Width = 80; this.dataGridView1.Columns[8].Width = 80; this.dataGridView1.Columns[9].Width = 80; var contentResult = WebRequestUtil.GetCommodityList(); if (contentResult != null) { var response = JsonUtil.Deserialize <QSWResponse <List <CommodityModel> > >(contentResult.Content); List <CommodityModel> commodityModelList = response.Data; foreach (var commodity in commodityModelList) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = commodity.CommodityName; this.dataGridView1.Rows[index].Cells[1].Value = commodity.CommodityGeneral; this.dataGridView1.Rows[index].Cells[2].Value = commodity.CommodityPrice; this.dataGridView1.Rows[index].Cells[3].Value = commodity.BrandName; this.dataGridView1.Rows[index].Cells[4].Value = commodity.CommodityCode; this.dataGridView1.Rows[index].Cells[5].Value = commodity.CommoditySpec; this.dataGridView1.Rows[index].Cells[6].Value = commodity.CommodityIndex; this.dataGridView1.Rows[index].Cells[7].Value = commodity.CommodityRH; this.dataGridView1.Rows[index].Cells[8].Value = commodity.CommodityFL; this.dataGridView1.Rows[index].Cells[9].Value = commodity.CommodityRM; this.dataGridView1.Rows[index].Tag = commodity; } } }