0

I want to create a delete function in context menu strip something like this:
enter image description here

I have created the code but it is not functioning. am I wrong or is there any other method to do this?

private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Int32 rowToDelete = dataGridView1.Rows.GetFirstRow(DataGridViewElementStates.Selected);
        dataGridView1.Rows.RemoveAt(rowToDelete);
        dataGridView1.ClearSelection();
    }
Ren
  • 765
  • 4
  • 15
  • 42
  • What does the debugger tell you about the value of rowToDelete? Did you put a breakpoint into the function to see what is going on? – Johann Blais Mar 11 '14 at 08:39
  • @JohannBlais it say Row index provided is out of range.any idea? – Ren Mar 11 '14 at 08:47

0 Answers0