我有一个使用 DataReader 作为其数据源的 DataGrid。我想隐藏数据网格的第一列。我正在使用 .net 紧凑框架 3.5。我可以找到 Windows 窗体的示例,但 api 已更改得足够多,以至于它们不起作用。
您可以将列样式宽度设置为0
or -1
.
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Order";
// Order date column style
DataGridColumnStyle cust_id = new DataGridTextBoxColumn();
cust_id.MappingName = "cust_id";
cust_id.HeaderText = "ID";
//Hide Customer ID
cust_id.Width = -1;
ts.GridColumnStyles.Add(cust_id);
// Shipping name column style
DataGridColumnStyle cust_name = new DataGridTextBoxColumn();
cust_name.MappingName = "cust_name";
cust_name.HeaderText = "Customer";
cust_name.Width = 500;
ts.GridColumnStyles.Add(cust_name);
GridView1.TableStyles.Add(ts);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)