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. bound datagridview new row problem

bound datagridview new row problem

Scheduled Pinned Locked Moved C#
helpcom
6 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.
  • E Offline
    E Offline
    Erdinc27
    wrote on last edited by
    #1

    hey guys..i have a bound datagridview in my form and i have two DataGridViewButtonColumn(Edit and Delete)...and the user can add new row..the problem is i want the DataGridViewButtonColumn to be seen as Insert and Cancel instead of Edit and Delete...after inserting process completed it must be seen like other datas..thanks for help

    vemedya.com

    N 1 Reply Last reply
    0
    • E Erdinc27

      hey guys..i have a bound datagridview in my form and i have two DataGridViewButtonColumn(Edit and Delete)...and the user can add new row..the problem is i want the DataGridViewButtonColumn to be seen as Insert and Cancel instead of Edit and Delete...after inserting process completed it must be seen like other datas..thanks for help

      vemedya.com

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      erdinc27 wrote:

      after inserting process completed it must be seen like other datas

      Not exactly sure what you mean by this, but, it sounds like perhaps you should use a TemplateColumn and adjust the button controls as required.


      I know the language. I've read a book. - _Madmatt

      E 1 Reply Last reply
      0
      • N Not Active

        erdinc27 wrote:

        after inserting process completed it must be seen like other datas

        Not exactly sure what you mean by this, but, it sounds like perhaps you should use a TemplateColumn and adjust the button controls as required.


        I know the language. I've read a book. - _Madmatt

        E Offline
        E Offline
        Erdinc27
        wrote on last edited by
        #3

        hii Mark thanks for reply.. i am searching that u suggested...here the pic what i mean..i mean when i have empty row as in pic the buttons' text must be seen as Add and cancel instead of Update and Delete...and after the user click Add button the row will be added(here no problem) and the button's text must be seen like Update and Delete..like the other buttons..i hope it is more clear now..thanks for help again

        vemedya.com

        N 1 Reply Last reply
        0
        • E Erdinc27

          hii Mark thanks for reply.. i am searching that u suggested...here the pic what i mean..i mean when i have empty row as in pic the buttons' text must be seen as Add and cancel instead of Update and Delete...and after the user click Add button the row will be added(here no problem) and the button's text must be seen like Update and Delete..like the other buttons..i hope it is more clear now..thanks for help again

          vemedya.com

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Handle the RowDataBound or RowCreated event and update the button text appropriately.


          I know the language. I've read a book. - _Madmatt

          E 1 Reply Last reply
          0
          • N Not Active

            Handle the RowDataBound or RowCreated event and update the button text appropriately.


            I know the language. I've read a book. - _Madmatt

            E Offline
            E Offline
            Erdinc27
            wrote on last edited by
            #5

            i couldnt find both events that u suggested...i have UserAddedRows and RowsAdded..i tried both

            private void datagridview1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
            {
            datagridview1.CurrentRow.Cells[6].Value = "Insert";
            }

            i cant catch Text Property here..that is why i used Value property but it gives error like "Object reference not set to an instance of an object." so what else i can try ?

            vemedya.com

            E 1 Reply Last reply
            0
            • E Erdinc27

              i couldnt find both events that u suggested...i have UserAddedRows and RowsAdded..i tried both

              private void datagridview1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
              {
              datagridview1.CurrentRow.Cells[6].Value = "Insert";
              }

              i cant catch Text Property here..that is why i used Value property but it gives error like "Object reference not set to an instance of an object." so what else i can try ?

              vemedya.com

              E Offline
              E Offline
              Erdinc27
              wrote on last edited by
              #6

              hi again.. thanks for help and your time..i solved my problem like below.in my button's click event that i create new row

              int rowCount = datagridview1.Rows.Count;
              DataGridViewButtonCell buttonCell = (DataGridViewButtonCell)datagridview1.Rows[rowCount].Cells[6];
              buttonCell.UseColumnTextForButtonValue = false;
              buttonCell.Value = "Insert";

              vemedya.com

              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