private void button1_Click(object sender, EventArgs e)
{
this.hostTableAdapter.Fill(this.hostScanDataSet.host);
}
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);
}
}