在C# DataGridView中设置列隐藏不起作用是怎么回事?
程序如下:DataGridViewTextBoxColumnsalerec_cid=newDataGridViewTextBoxColumn();DataGridView...
程序如下:
DataGridViewTextBoxColumn salerec_cid = new DataGridViewTextBoxColumn();
DataGridViewTextBoxColumn salerec_spid = new DataGridViewTextBoxColumn();
DataGridViewTextBoxColumn salerec_date = new DataGridViewTextBoxColumn();
DataGridViewTextBoxColumn salerec_detail = new DataGridViewTextBoxColumn();
salerec_spid.Name = "spid"; //主键
salerec_spid.HeaderText = "拿货批次";
salerec_spid.DataPropertyName = "spid";
salerec_spid.Visible = false;
dg_salerec.Columns.Add(salerec_spid);
salerec_cid.Name = "cid";
salerec_cid.HeaderText = "顾客编号";
salerec_cid.DataPropertyName = "cid";
salerec_cid.Visible = false;
dg_salerec.Columns.Add(salerec_cid);
salerec_date.Name = "sdate";
salerec_date.HeaderText = "时间";
salerec_date.DataPropertyName = "sdate";
dg_salerec.Columns.Add(salerec_date);
salerec_detail.Name = "detail";
salerec_detail.HeaderText = "说明";
salerec_detail.DataPropertyName = "detail";
salerec_detail.Width = 200;
dg_salerec.Columns.Add(salerec_detail);
运行时,顾客编号这一列被隐藏了,但拿货批次这一列还是被显示出来了。这是怎么回事? 展开
DataGridViewTextBoxColumn salerec_cid = new DataGridViewTextBoxColumn();
DataGridViewTextBoxColumn salerec_spid = new DataGridViewTextBoxColumn();
DataGridViewTextBoxColumn salerec_date = new DataGridViewTextBoxColumn();
DataGridViewTextBoxColumn salerec_detail = new DataGridViewTextBoxColumn();
salerec_spid.Name = "spid"; //主键
salerec_spid.HeaderText = "拿货批次";
salerec_spid.DataPropertyName = "spid";
salerec_spid.Visible = false;
dg_salerec.Columns.Add(salerec_spid);
salerec_cid.Name = "cid";
salerec_cid.HeaderText = "顾客编号";
salerec_cid.DataPropertyName = "cid";
salerec_cid.Visible = false;
dg_salerec.Columns.Add(salerec_cid);
salerec_date.Name = "sdate";
salerec_date.HeaderText = "时间";
salerec_date.DataPropertyName = "sdate";
dg_salerec.Columns.Add(salerec_date);
salerec_detail.Name = "detail";
salerec_detail.HeaderText = "说明";
salerec_detail.DataPropertyName = "detail";
salerec_detail.Width = 200;
dg_salerec.Columns.Add(salerec_detail);
运行时,顾客编号这一列被隐藏了,但拿货批次这一列还是被显示出来了。这是怎么回事? 展开
2个回答
2014-04-29
展开全部
添加列时,每一列都会有一个可见属性,设置为false就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询