从网格视图中删除列(VB.NET 2008)



{使用Northwind Microsoft数据库的VB.NET 2008}如何才能从demogrid中删除名称类似id的列?(不使用sql代码)

    Dim strSQL As String = _
     "SELECT * FROM Products WHERE CategoryID=1"
    Try
        Using adapter As New OleDbDataAdapter(strSQL, _
          My.Settings.OleDbConnectionString)
            Dim ds As New DataSet
            adapter.Fill(ds, "ProductInfo")

            demoList.DisplayMember = "ProductName"
            demoList.ValueMember = "ProductID"
            demoGrid.DataSource = ds.Tables("ProductInfo")
        End Using
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

您可以删除不喜欢的列

GridViewName.Columns.Remove("ColumnName")

相关内容

  • 没有找到相关文章

最新更新