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

datagridview

Scheduled Pinned Locked Moved C#
question
5 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.
  • F Offline
    F Offline
    farokhian
    wrote on last edited by
    #1

    Hi all How can i add a column to mydatagridview in code that the duty of this row is deleting the current row?

    D H 2 Replies Last reply
    0
    • F farokhian

      Hi all How can i add a column to mydatagridview in code that the duty of this row is deleting the current row?

      D Offline
      D Offline
      Dr Walt Fair PE
      wrote on last edited by
      #2

      Basically you need to create a column and add it to the columns collection. As far as it's duty, I have no idea what you are talking about!

      CQ de W5ALT

      Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

      F 1 Reply Last reply
      0
      • D Dr Walt Fair PE

        Basically you need to create a column and add it to the columns collection. As far as it's duty, I have no idea what you are talking about!

        CQ de W5ALT

        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

        F Offline
        F Offline
        farokhian
        wrote on last edited by
        #3

        Thanks for your help; I mean that I want a column for deleting the current row that has been clicked; Additionally i want a gridview that has a deleting ability and i want to add this ability to my datagrtidview in code.

        D 1 Reply Last reply
        0
        • F farokhian

          Thanks for your help; I mean that I want a column for deleting the current row that has been clicked; Additionally i want a gridview that has a deleting ability and i want to add this ability to my datagrtidview in code.

          D Offline
          D Offline
          Dr Walt Fair PE
          wrote on last edited by
          #4

          Well, in my applications, selecting the row header and pressing the delete key deletes the row. If you need something different, then maybe using a checkbox or button column and doing the delete when that is selected would work, but it seems convoluted to me. Or maybe I still don't understand what you want to do?

          CQ de W5ALT

          Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

          1 Reply Last reply
          0
          • F farokhian

            Hi all How can i add a column to mydatagridview in code that the duty of this row is deleting the current row?

            H Offline
            H Offline
            hamed vojdani
            wrote on last edited by
            #5

            Hi, add a ButtonColumn to DataGridView and name it like Colremove then write code for dataGridView CellContentClick event like shown below

                private void dataGridView1\_CellContentClick(object sender, DataGridViewCellEventArgs e)
                {
                    if (e.RowIndex > -1)
                    {
                        if (e.ColumnIndex == dataGridView1.Columns\["dataGridView1.Colremove"\].Index)
                        {
                            dataGridView1.Rows.RemoveAt(e.RowIndex);
                        }
            
                    }
                }
            

            modified on Friday, December 18, 2009 1:55 PM

            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