954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Delete & Add button in datagridview

Hi,
I want to make an inventory program and I need help with how to put an add and a delete button in a column. I want that the delete button deletes the row and when I click the edit button a forms comes up so I can edit the information.

Check the link below to see the image from my program.
http://img534.imageshack.us/img534/5181/inventorysss.jpg

Exaktor
Light Poster
31 posts since Apr 2010
Reputation Points: 19
Solved Threads: 0
 

To make a button in the column, use the DataGridViewButtonColumn object. Then, you can create an onclick event to handle your editing/deleting.

DataGridViewButtonColumn buttonColumn = 
            new DataGridViewButtonColumn();
        buttonColumn.HeaderText = "Delete/Edit";

I know that code to remove a row is:

DataGridView1.Rows.RemoveAt(index)


Hope that helps.

BDS_AT
Newbie Poster
7 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

Now I made an edit button. What is the code so a new form shows up when i click the button and where should I put that code?

Should I put the code inside the code below or somewhere else.

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
Exaktor
Light Poster
31 posts since Apr 2010
Reputation Points: 19
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You