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. .NET (Core and Framework)
  4. Datagridview

Datagridview

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharphelpquestion
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.
  • K Offline
    K Offline
    kindman_nb
    wrote on last edited by
    #1

    Hi all I'm using datagridview with vb.net, I have a CHECKBOX COLUMN then I fill it I use CellContentClick event that when the user change the CHECKBOX COLUMN vlue then do ......... something what is happened, when the user change CHECKBOX COLUMN value the CellContentClick is firing , for eg: CHECKBOX COLUMN value before click = true after click will be = false when I go to get it's value

    Dim chk As Boolean
    chk = MyDataGridView.CurrentRow.Cells("Col_Check").Value)

    it's still keeping its orginal value (True) it's saving the new value after you change the row if any one can help thank you

    jooooo

    D G 3 Replies Last reply
    0
    • K kindman_nb

      Hi all I'm using datagridview with vb.net, I have a CHECKBOX COLUMN then I fill it I use CellContentClick event that when the user change the CHECKBOX COLUMN vlue then do ......... something what is happened, when the user change CHECKBOX COLUMN value the CellContentClick is firing , for eg: CHECKBOX COLUMN value before click = true after click will be = false when I go to get it's value

      Dim chk As Boolean
      chk = MyDataGridView.CurrentRow.Cells("Col_Check").Value)

      it's still keeping its orginal value (True) it's saving the new value after you change the row if any one can help thank you

      jooooo

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      From what I vaguely remember, EditedFormattedValue will have the updated cell value.

      Finally is not executed always. As told by Sir Pete and PiebaldConsult. Go figure.

      1 Reply Last reply
      0
      • K kindman_nb

        Hi all I'm using datagridview with vb.net, I have a CHECKBOX COLUMN then I fill it I use CellContentClick event that when the user change the CHECKBOX COLUMN vlue then do ......... something what is happened, when the user change CHECKBOX COLUMN value the CellContentClick is firing , for eg: CHECKBOX COLUMN value before click = true after click will be = false when I go to get it's value

        Dim chk As Boolean
        chk = MyDataGridView.CurrentRow.Cells("Col_Check").Value)

        it's still keeping its orginal value (True) it's saving the new value after you change the row if any one can help thank you

        jooooo

        G Offline
        G Offline
        Ger Hayden
        wrote on last edited by
        #3

        I'll have a look at my code over the week end or Monday. I think I have a working example. GER

        Ger

        1 Reply Last reply
        0
        • K kindman_nb

          Hi all I'm using datagridview with vb.net, I have a CHECKBOX COLUMN then I fill it I use CellContentClick event that when the user change the CHECKBOX COLUMN vlue then do ......... something what is happened, when the user change CHECKBOX COLUMN value the CellContentClick is firing , for eg: CHECKBOX COLUMN value before click = true after click will be = false when I go to get it's value

          Dim chk As Boolean
          chk = MyDataGridView.CurrentRow.Cells("Col_Check").Value)

          it's still keeping its orginal value (True) it's saving the new value after you change the row if any one can help thank you

          jooooo

          G Offline
          G Offline
          Ger Hayden
          wrote on last edited by
          #4

          Here is how I use the checkbox column in a DataGridView using C++/CLI. I load my datagrid launching my forms. In my RowEntered function I dislay the value of the checkbox from the grid in a static region of the screen. I am currently using a try/catch construct.

          try
          {
          	chkRegistered->Checked = (bool)gridPerson->Rows\[e->RowIndex\]->Cells\[dgRegistered->Index\]->Value;
          }
          catch(Exception ^e)
          {
          	chkRegistered->Checked = false;
          }
          

          I have also used (but since stopped) an if statement for this purpose.

          if (gridPerson->Rows\[e->RowIndex\]->Cells\[9\]->Value == true)
          	chkRegistered->Checked = true;
          else
          	chkRegistered->Checked = false;
          

          This is an extract from the CellValueChanged Event where I capture the checkbox value for storage:

          case 9:
          	{
          		chkRegistered->Checked = safe\_cast<bool>(gridPerson->Rows\[e->RowIndex\]->Cells\[9\]->Value);
          		m\_ElementList = m\_ElementList | m\_FlagBits::REGISTERED;
          		break;
          	}
          

          One last thing, have a look at the code converters from www.tangiblesoftwaresolutions.com - I use them to convert snippets from VB and C# to C++ for my use. Regards

          Ger

          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