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. Windows Forms
  4. dataGridView Binding

dataGridView Binding

Scheduled Pinned Locked Moved Windows Forms
csswpfwcf
2 Posts 2 Posters 3 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.
  • A Offline
    A Offline
    Ali el
    wrote on last edited by
    #1

    i have a gridview and bind it to datasource. gridview has a bounded boolean column. i want if grid to be not editable expect those cells in the boolean column where value is false. in other words: all columns are readonly expect the boolean column not readonly. if the value of the cell in boolean column 1- true: the cell is readonly 2- false: the cell is not readonly i tried this code but i do not know why it does not work. For Each x As DataGridViewRow In DataGridView1.Rows If x.Cells("DeductionAdded").Value.ToString.ToLower = "true" Then x.Cells("DeductionAdded").ReadOnly = True End If Next

    G 1 Reply Last reply
    0
    • A Ali el

      i have a gridview and bind it to datasource. gridview has a bounded boolean column. i want if grid to be not editable expect those cells in the boolean column where value is false. in other words: all columns are readonly expect the boolean column not readonly. if the value of the cell in boolean column 1- true: the cell is readonly 2- false: the cell is not readonly i tried this code but i do not know why it does not work. For Each x As DataGridViewRow In DataGridView1.Rows If x.Cells("DeductionAdded").Value.ToString.ToLower = "true" Then x.Cells("DeductionAdded").ReadOnly = True End If Next

      G Offline
      G Offline
      Gopal S
      wrote on last edited by
      #2

      Hi 1) Fetch your data to datatable 2) Bind data table to the datagrid. 3) then, you can use your previous code. Now it works fine. Thanks.

      Gopal.S

      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