Advertisement
5_2007-2008 String Manipulation #183222

Hide & Disable Columns in DataGrid

This few lines of Code demonstrate how to Hide & Disable(lock) columns in Datagrid. Taking example from Northwind database it allows user to modify only ContactName,Phone and Fax columns. Add this code in Form load event and modify the Connection string if required. also add Imports System.Data.SqlClient in your code. hope it helps you.

AI

Resumen de IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Código fuente
original-source
Dim CN As New SqlConnection("server=(local);Database=Northwind;User ID=sa;password=;")
 CN.Open()
 Dim DA As New SqlDataAdapter("Select CustomerID, CompanyName, ContactName, Phone, Fax from Customers order by 1", CN)
 Dim DS As New DataSet()
 'DA.FillSchema(DS, SchemaType.Source, "Cust")
 DA.Fill(DS, "Cust")
 DS.Tables("Cust").Columns("CustomerID").ColumnMapping = MappingType.Hidden
 DS.Tables("Cust").Columns("CompanyName").ReadOnly = True
 DataGrid1.SetDataBinding(DS, "Cust")
Upload
Comentarios originales (3)
Recuperado de Wayback Machine