Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How can I Edit a Readonly DataGrid?

How can I Edit a Readonly DataGrid?

Scheduled Pinned Locked Moved C#
questioncsharp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mkomasi
    wrote on last edited by
    #1

    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.

    H 1 Reply Last reply
    0
    • M mkomasi

      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.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 a DataSet, which you should use the DataTable.DefaultView to take into account any re-ordering), you can re-data-bind your control either by setting the DataSource property to null and then back to the DataSet (or whatever), or refresh the CurrencyManager like so:

      CurrencyManager cm = (CurrentyManager)
      dataGrid1.BindingContext[dataGrid1.DataSource,
      dataGrid1.DataMember];
      if (cm != null) cm.Refresh();

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups