hellboy
hellboy

Reputation: 1618

Make DataGrid cells readonly

There is DataGrid (WinForms / .NET CF 3.5) bounded with DataSource to list object. How to disable data editing in cells?

Upvotes: 1

Views: 927

Answers (2)

Tonix
Tonix

Reputation: 177

Try this,

dt.Columns(0).ReadOnly = True '// Make the column(0) readonly and assign to DataGrid.

dataGridView1.DataSource = dt

This code can make any column you set as read only. By the way,

dt

represents as datatable that is used to gather data from database and its datasource to the datagrid dataGridView1.

Upvotes: 1

denied66
denied66

Reputation: 644

You can try using DataGridView instead of DataGrid and set it's EditMode property to EditProgrammatically

  dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;

Upvotes: 0

Related Questions