从GridView中删除列(VB.NET 2008)

时间:2015-10-30 20:57:09

标签: vb.net gridview oledbconnection

{VB.NET 2008使用Northwind Microsoft Database} 如何从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

1 个答案:

答案 0 :(得分:0)

You can remove the column you don't like

GridViewName.Columns.Remove("ColumnName")