你如何使用隐藏在.NET Compact Framework 3.5在DataGrid列 [英] How do you hide a column in a datagrid using the .net compact framework 3.5

查看:178
本文介绍了你如何使用隐藏在.NET Compact Framework 3.5在DataGrid列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用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);

这篇关于你如何使用隐藏在.NET Compact Framework 3.5在DataGrid列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆