Delete GridView Row in Windows Forms

I have a GridView and in each item of this grid I have a Button that I use to delete the row of these button. But it is not working.

private void grvOrders_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        var senderGrid = (DataGridView)sender;                   

        if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
            e.RowIndex >= 0)
        {
           grvOrders.Rows.Remove(sender);
        }
    }

anyone could help me?

Answers


Your problem is you can't remove the sender: it's not a DataGridViewRow. Instead, use grvOrders.Rows.RemoveAt(e.RowIndex);.


Need Your Help

Username and password of Jenkins on Openshift

jenkins openshift

I've installed Jenkins via Openshift redhat (https://openshift.redhat.com) .. The installation of Jenkins is done..

"Go To" and "Back To" in Google Docs API?

html google-docs-api presentation

How can I set a page, go to a next or go to the previous page in a Presentation of Google Docs using the Google Docs List API v3?, is possible to do them?.