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. DataGridView prevent edit

DataGridView prevent edit

Scheduled Pinned Locked Moved C#
question
4 Posts 3 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.
  • J Offline
    J Offline
    Johnny 0
    wrote on last edited by
    #1

    Is there a way to prevent edit of some columns in a DataGridView bound to a DataTable? What I need is prevent edit, the user shouldn't have the opportunity to enter in edit mode if the celll belongs to one of the columns I consider "Read Only".

    L J G 3 Replies Last reply
    0
    • J Johnny 0

      Is there a way to prevent edit of some columns in a DataGridView bound to a DataTable? What I need is prevent edit, the user shouldn't have the opportunity to enter in edit mode if the celll belongs to one of the columns I consider "Read Only".

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi As far as I know ... this is can't be done in C# (2003 ) .net 1.1 but I know a cool and open Source DataGrid for .net 2.0 can solve this prb check this link www.codeproject.com/cs/miscctrl/csharpgridcontrol.asp and sorry if I got so far from your Question .... I just wanted to help .....

      I know nothing , I know nothing

      1 Reply Last reply
      0
      • J Johnny 0

        Is there a way to prevent edit of some columns in a DataGridView bound to a DataTable? What I need is prevent edit, the user shouldn't have the opportunity to enter in edit mode if the celll belongs to one of the columns I consider "Read Only".

        J Offline
        J Offline
        Johnny 0
        wrote on last edited by
        #3

        If this helps anybody I captured the DataGridView.CellParsing event and forced a EndEdit() Not very elegant but it prvents user from entering anything

        1 Reply Last reply
        0
        • J Johnny 0

          Is there a way to prevent edit of some columns in a DataGridView bound to a DataTable? What I need is prevent edit, the user shouldn't have the opportunity to enter in edit mode if the celll belongs to one of the columns I consider "Read Only".

          G Offline
          G Offline
          ganti r
          wrote on last edited by
          #4

          Hi Johnny, Tables(0).Columns(0).ReadOnly= True Now bind this datatable to the Datagridview. The column 0 is readonly and will not enter into edit mode.

          rAm i Think, i Wait, i Fast -- Siddartha

          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