1 判断文本框中输入的IP地址是否合法
Regex reg = new Regex(@"(?n)^(([1-9]?[0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))/.){3}([1-9]?[0-9]|1[0-9]{2}|2([0-4][0-9]|5[0-5]))$");
if (reg.IsMatch(tb_IP.Text))
lb_IP.Items.Add(tb_IP.Text);
else
MessageBox.Show("It's not a variable IP!");
2 C#删除listbox中选定的项
//确定消息头
string title = "Confirmation";
//确定消息正文
string text = "Are you sure,you want to delete selected filter value(s)?";
DialogResult m_dr = MessageBox.Show(text, title, MessageBoxButtons.YesNo);
if (m_dr==DialogResult.Yes)
{
lb_IP.Items.Remove(lb_IP.SelectedItem);
}