zoukankan      html  css  js  c++  java
  • DataGrid隐藏列

    3种方式:
    1)利用DataSet's ColumnMapping property
    // Creating connection and command sting
    string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb";
    string sqlStr = "SELECT * FROM Employees";
    // Create connection object 
     OleDbConnection conn = new OleDbConnection(conStr);
    // Create data adapter object
    OleDbDataAdapter da = new OleDbDataAdapter(sqlStr,conn);
    // Create a dataset object and fill with data using data adapter's Fill method 
     DataSet ds = new DataSet();
    da.Fill(ds, "Employees"); 
     // Hide the column and attach dataset's DefaultView to the datagrid control
    ds.Tables["Employees"].Columns["LastName"].ColumnMapping = MappingType.Hidden;       // ***
     dataGrid1.DataSource = ds.Tables["Employees"];

    2) 设置width to zero.
    3) Another way to hide a column is to create a custom table style, and as you add columnstyles to your tablestyle, omit the column you want hidden.
  • 相关阅读:
    matlab绘制椭圆 ezplot
    matlab绘制函数 y=ln(1+x)
    matlab绘制函数 y=e^(x)
    matlab绘制函数
    matlab绘制函数
    matlab绘制函数
    常用求导公式复习
    积分变换
    复变函数
    概率论与数理统计目录
  • 原文地址:https://www.cnblogs.com/flashicp/p/765163.html
Copyright © 2011-2022 走看看