private void button2_Click(object sender, EventArgs e)
{
this.hostTableAdapter.Update(this.hostScanDataSet.host);
MessageBox.Show("记录已保存!");
}
private void button3_Click(object sender, EventArgs e)
{
DialogResult dlResult = MessageBox.Show(this, "要删除这些记录吗?", "请确认",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign);
if (dlResult == DialogResult.Yes)
{
int j = dataGridView1.SelectedRows.Count;
int[] l = new int[j];
int i;
for (i = 0; i < j; i++)
{
l[i] = dataGridView1.SelectedRows[i].Index;
}
int k = 0;
while (k < j)
{
this.hostScanDataSet.host.Rows[l[k]].Delete();
k++;
}
this.hostTableAdapter.Update(this.hostScanDataSet.host);
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/785292/viewspace-1052649/ ,如需转载,请注明出处,否则将追究法律责任。