private void buttonMoveUp_Click(object sender, EventArgs e) { try { int index = listBox1.SelectedIndex; if (index != 0) { Rule rule = (Rule)listBox1.Items[index]; listBox1.Items.RemoveAt(index); index--; listBox1.Items.Insert(index, rule); listBox1.SelectedIndex = index; List <Rule> r = new List <Rule>(); foreach (object ru in listBox1.Items) { r.Add((Rule)ru); } basicfirewall.InstanceGetRuleUpdates(r); } } catch { } }