How can I Edit a Readonly DataGrid?
-
Hi, I want to edit just a cell or a row in a DataGrid. I think that I have to set Readonly property to true, but when I change this property to false all cells and rows will be editable. I know I can have it easily in web application, but I want to know how can I do it in C# windows application.
-
Hi, I want to edit just a cell or a row in a DataGrid. I think that I have to set Readonly property to true, but when I change this property to false all cells and rows will be editable. I know I can have it easily in web application, but I want to know how can I do it in C# windows application.
Edit the data itself and update the
DataGrid
. This works different than in ASP.NET because it is different that in ASP.NET. In Windows Forms, it's a control. In ASP.NET, it simply generates different HTML based on state. There's a big difference. Once you've edited the data (like aDataSet
, which you should use theDataTable.DefaultView
to take into account any re-ordering), you can re-data-bind your control either by setting theDataSource
property tonull
and then back to theDataSet
(or whatever), or refresh theCurrencyManager
like so:CurrencyManager cm = (CurrentyManager)
dataGrid1.BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember];
if (cm != null) cm.Refresh();Microsoft MVP, Visual C# My Articles