//DataGridview绑定数据 public void DataGridViewBandingData() { string year = this.CMB_year.SelectedValue.ToString(); //年份 string leibie = ((CListItem)this.CBXLeiBie.SelectedItem).Id; //类别 string bianhaoquan = this.txtBianhaoquan.Text; //编号权 string shixiangmingcheng = this.txtshixiangmingcheng.Text; //事项名称 string farendaima = this.txtfarendaima.Text; //法人代码 DataSet ds = bll.GetJiChuShuJu(leibie, year, bianhaoquan, shixiangmingcheng, farendaima); DataGridViewCheckBoxColumn myCol = new DataGridViewCheckBoxColumn(); //创建复选框 myCol.Selected = false; this.DataGridView.Columns.Add(myCol); this.DataGridView.ColumnCount = 8; //指定列数 this.DataGridView.ColumnHeadersVisible = true; //是否显示猎头 this.DataGridView.AutoGenerateColumns = false; this.DataGridView.Columns[0].HeaderText = "全选"; this.DataGridView.Columns[0].DataPropertyName = ""; //ds.Tables[0].Columns["HangBiaoShi"].ToString() this.DataGridView.Columns[0].Width = 60; this.DataGridView.Columns[1].HeaderText = "年份"; this.DataGridView.Columns[1].DataPropertyName = ds.Tables[0].Columns["BianHaoNian"].ToString(); this.DataGridView.Columns[2].HeaderText = "编号权"; this.DataGridView.Columns[2].DataPropertyName = ds.Tables[0].Columns["BianHaoQuan"].ToString(); this.DataGridView.Columns[2].Width = 180; this.DataGridView.Columns[3].HeaderText = "事项名称"; this.DataGridView.Columns[3].DataPropertyName = ds.Tables[0].Columns["ShiXiangMingCheng"].ToString(); this.DataGridView.Columns[3].Width = 300; this.DataGridView.Columns[4].HeaderText = "法人代码"; this.DataGridView.Columns[4].DataPropertyName = ds.Tables[0].Columns["FaRenDaiMa"].ToString(); this.DataGridView.Columns[5].HeaderText = "行标示"; this.DataGridView.Columns[5].DataPropertyName = ds.Tables[0].Columns["HangBiaoShi"].ToString(); this.DataGridView.Columns[5].Width = 100; this.DataGridView.Columns[5].Visible = true; this.DataGridView.Columns[6].HeaderText = "登记标识"; this.DataGridView.Columns[6].DataPropertyName = ds.Tables[0].Columns["dengjibiaoshi"].ToString(); this.DataGridView.Columns[6].Width = 100; this.DataGridView.Columns[7].HeaderText = "当事人"; this.DataGridView.Columns[7].DataPropertyName = ds.Tables[0].Columns["dangshiren"].ToString(); this.DataGridView.Columns[7].Width = 300; this.DataGridView.DataSource = ds.Tables[0]; }