Reputation: 45
I know there must be a simple solution to this question, but I seem to be missing the answer. I have a Visual Studio 2008 Winforms application where I created a datagridview to display data to users. In the datagridview I allow the users to edit information. One of the cells is set to read only and the users want to be able to edit this information now. When I go into the datagridview designer to set the cell to Readonly = False the change does not get saved. Does not matter what I do the change WILL not get saved. I am now looking into changing this at run time using the code below:
When I use that code I get the error mentioned in the title. It seems to me that I am stuck now... I can't change the cell to readonly = false using the Visual Studio designer. I can't set the cell to readonly = false at runtime.
Question: What am I doing wrong? Is there something else I can do? This is quite a sizable application for multiple users and this is a request made by most of the users.
Any help would be appreciated.
Dim oDL As New MTN.BusinessLayer.MasterTables()
Dim dt As DataTable = oDL.GetTheItems() DataGridView1.DataSource = dt
Upvotes: 4
Views: 9059
Reputation: 1
First Set DataTable ReadOnly Property False. Then Set Gridview ReadOnly Property false.
EX-
DataTable dt=("Select * prom priceList");
dt.Columns["Rate"].ReadOnly = false;
DataGrid View dgv=.dataSource=dt;
dgv.Columns["Rate"].ReadOnly = false;
Upvotes: 0
Reputation: 686
You can actually set the ReadOnly property for the DataTable column!
Dim dt As DataTable = oDL.GetTheItems()
dt.Columns("Selected").ReadOnly = false
DataGridView1.DataSource = dt
Upvotes: 4
Reputation: 913
Have you tried? (setting properties) :
AllowUserToAddRows = False
AllowUserToDeleteRows = False
ReadOnly = True
Upvotes: 0