To delete a row in access table from datagridView using ContextMenuStrip

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tanuja5
    New Member
    • Jan 2009
    • 4

    To delete a row in access table from datagridView using ContextMenuStrip

    hi..
    how to delete the selected row in datagridview using ContextMenuStri p.When i right-click and press "delete" the seleted row in the dataGridView has to be deleted and as well in my access table.I am new to C#.net

    my coding is this:
    Code:
                int curRow = 0;
                curRow = this.dataGridView1.CurrentRow.Index;
                this.dataGridView1.Rows.RemoveAt(curRow);
    but it is deleting only in datagridView and it is not getting updated in my access table.plz help me with the code,where i should write my query to delete based on the selected row .plz help me
    Last edited by pbmods; Jan 24 '09, 07:58 AM. Reason: Added CODE tags.
  • skepar
    New Member
    • Mar 2009
    • 1

    #2
    Hi there !
    I got the same problem check out this:
    # int curRow = 0;
    # curRow = this.dataGridVi ew1.CurrentRow. Index;
    # this.dataGridVi ew1.Rows.Remove At(curRow);
    ->this.tableAdap terManager.Upda teAll(this.Your DataSet);<-

    Comment

    • watsonsimler
      New Member
      • Jun 2014
      • 1

      #3
      private void contextMenuStri p1_Click(object sender, EventArgs e)
      {
      if (!this.dataGrid View1.Rows[this.rowIndex].IsNewRow)
      {
      this.dataGridVi ew1.Rows.Remove At(this.rowInde x);
      }
      }

      Full source...Delete from datagridview on right click

      watson

      Comment

      Working...