contextMenuStrip控件,用datagridview关联这个控件。
itemclick事件。。

解决方案 »

  1.   

    绑定的源里Remove这条记录就好了。。
    如果源不能实时更新,你要重新赋源
      

  2.   

    给dataGridView加个CellMouseClick事件void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        if (e.Button == System.Windows.Forms.MouseButtons.Right)
        {
             if (MessageBox.Show("您确定要删除本条信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) 
             {
                 SqlCommand cmd = new SqlCommand(string.Format("delete 表名 where cno= '{0}'", dataGridView1.Rows[e.RowIndex].Cells[1].Value), new SqlConnection());
                 cmd.ExecuteNonQuery();
                 //在这里调用你写的代码重新绑定;
             }
        }
    }
      

  3.   

    private void DataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        foreach (DataGridViewRow r in DataGridView1.SelectedRows)
         {  
          if (!r.IsNewRow)
          {        
           DataGridView1.Rows.Remove(r);   
          }
       }
    }
      

  4.   

    给该控件添加 点击事件--这个不用教吧,判断e.Button是不是右击的,是就取得行索引值,datagridview.rows.removeat(index),