你如何使用隐藏在.NET Compact Framework 3.5在DataGrid列如何使用、NET、Compact、DataGrid

由网友(咕嘟咕嘟冒个泡)分享简介:我有一个使用DataReader作为其数据源的一个DataGrid。我想隐藏DataGrid的第一列。我使用.NET Compact Framework的3.5。我能找到的例子窗口的形式,但空气污染指数是改变了,以至于他们不工作。I have a DataGrid that is using a DataReader...

我有一个使用DataReader作为其数据源的一个DataGrid。我想隐藏DataGrid的第一列。我使用.NET Compact Framework的3.5。我能找到的例子窗口的形式,但空气污染指数是改变了,以至于他们不工作。

I have a DataGrid that is using a DataReader as its datasource. I want to hide the first column of the datagrid. I am using the .net compact framework 3.5. I can find examples for windows forms but the api is changed enough that they don't work.

推荐答案

您可以设置列宽样式为0或-1。

You can set the column style width to 0 or -1.

的DataGridTableStyle TS =新的DataGridTableStyle();             ts.MappingName =订单;

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);
阅读全文

相关推荐

最新文章