添一些值到空列啊例如NAV
删除的话如果有值不就不能显示了?

解决方案 »

  1.   

    对不起我表达的不对,应该是datagrid显示时候把多余的空值列隐藏。
      

  2.   

    Dim i, j As Integer
            For i = 0 To MyDataGrid.Items.Count - 1
                For j = 0 To MyDataGrid.Columns.Count - 1
                    If MyDataGrid.Items(i).Cells(j).Text = "" Then
                        MyDataGrid.Columns(j).Visible = False
                    End If
                Next
            Next
      

  3.   

    哦,写出来了,可是还不行啊?
    代码: DataGrid1.DataSource=ds1.Tables[0].DefaultView;


    int x,y;
    for(x=0;x<DataGrid1.Items.Count;x++)
    {  for(y=0;y<DataGrid1.Columns.Count;y++)
     if (DataGrid1.Items[x].Cells[y].Text==" ")
     DataGrid1.Columns[y].Visible=false;
    }DataGrid1.DataBind();
      

  4.   

    没他们讲的那么复杂!只要创建一个dataview,dataview关联dataset中的表,再把datagrid的datasource设置成dataview,然后在dataview的属性你设置allownew为false,这样就可以不显示讨厌的带*号的那行空白的新增行.当然datagrid还是可修改的.
      

  5.   

    是不是windows.forms命名空间下的DataGrid?
    如果是的话,遍历TableStyles,取得每一个DataGridColumnStyles,将其MapingName设为空就可以隐藏列,设为字段名就可以显示列
      

  6.   

    类名搞错了,是这样的
    foreach(DataGridColumnStyle dgcs in this.TableStyles["表名"].GridColumnStyles  )
    {
      dgcs.MappingName ="";
    }