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. Datagrid view

Datagrid view

Scheduled Pinned Locked Moved C#
help
4 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.
  • H Offline
    H Offline
    hiremath71
    wrote on last edited by
    #1

    hi, i am using a datagrid view and one of the column type is datagridviewcheckbox now i need to enable/disable the entire row based on the selection of that checkbox help me pls with regards prasad:)

    J 1 Reply Last reply
    0
    • H hiremath71

      hi, i am using a datagrid view and one of the column type is datagridviewcheckbox now i need to enable/disable the entire row based on the selection of that checkbox help me pls with regards prasad:)

      J Offline
      J Offline
      joon vh
      wrote on last edited by
      #2

      A quick example code. Add this to the CellClick event of the DataGridView. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { foreach (DataGridViewCell cell in dataGridView1.Rows[e.RowIndex].Cells) { cell.Value = "Nooooo"; } } } Enabling or disabling a row I don't really know how to do. You should explore the options of DataGridViewCell and DataGridViewRow in the object browser. Let me know when you find it. greetz


      Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

      H 1 Reply Last reply
      0
      • J joon vh

        A quick example code. Add this to the CellClick event of the DataGridView. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { foreach (DataGridViewCell cell in dataGridView1.Rows[e.RowIndex].Cells) { cell.Value = "Nooooo"; } } } Enabling or disabling a row I don't really know how to do. You should explore the options of DataGridViewCell and DataGridViewRow in the object browser. Let me know when you find it. greetz


        Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

        H Offline
        H Offline
        hiremath71
        wrote on last edited by
        #3

        hi, it is filling the rest of the rows with specified value.. but i want to disable/enale that row .. i am trying but not getting help me pls.. with regards prasad:)

        J 1 Reply Last reply
        0
        • H hiremath71

          hi, it is filling the rest of the rows with specified value.. but i want to disable/enale that row .. i am trying but not getting help me pls.. with regards prasad:)

          J Offline
          J Offline
          joon vh
          wrote on last edited by
          #4

          As I said, I don't think it's possible to disable a row in a datagrid. You could set it's ReadOnly property to true, or Frozen.

                     if (e.ColumnIndex == 2)
                     {
                        // standard value is null, unchecked
                        if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ||
                            (bool)(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]).Value == false)
                        {
                           dataGridView1.Rows[e.RowIndex].ReadOnly = true;
                           dataGridView1.Rows[e.RowIndex].Frozen = true;
                           // set it to checked
                           dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true;
                        }
                        else
                        {
                            dataGridView1.Rows[e.RowIndex].ReadOnly = false;
                            dataGridView1.Rows[e.RowIndex].Frozen = false;
                            // set it to unchecked
                            dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = false;
                        }
                     }
          

          Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

          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