如何使用.net compact framework 3.5在数据网格中隐藏列

run*_*ier 4 .net c# datagrid compact-framework windows-mobile

我有一个使用DataReader作为其数据源的DataGrid.我想隐藏数据网格的第一列.我正在使用.net紧凑框架3.5.我可以找到Windows窗体的示例,但api已经改变,它们不起作用.

NET*_*rts 12

您可以将列样式宽度设置为0-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);
Run Code Online (Sandbox Code Playgroud)