//限制文本框只能输入数字且允许按退格键删除数字,其它键盘输入不予显示
private void 文本框名_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
{
e.Handled = true;
}
}
//listview限制只能在查询出的有效数据记录行内出现右键菜单,其它空白处不许出现
private void 右键菜单名_Opening(object sender, CancelEventArgs e)
{
if (this.listview1.SelectedItems.Count <= 0)
{
e.Cancel = true;
}
}
//在listview查询出数据后,表中右键删除记录后,实时将表中该条数据移除
listview1.Items.Remove(listview1.SelectedItems[0])