예제 #1
0
        private void btnAddIp_Click(object sender, EventArgs e)
        {
            frmEditIp frmEdit = new frmEditIp();
            frmEdit.EditMode = false;
            frmEdit.Username = txtUsername.Text;
            frmEdit.Mac = GetChosenMac();
            var result = frmEdit.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
                listIpAddresses.Items.Add(new IpListItem(frmEdit.Username, frmEdit.Ip, frmEdit.Mac));
        }
예제 #2
0
        private void btnEditIp_Click(object sender, EventArgs e)
        {
            if (listIpAddresses.SelectedItems.Count == 0)
                return;

            IpListItem item = (IpListItem) listIpAddresses.SelectedItem;

            frmEditIp frmEdit = new frmEditIp();
            frmEdit.Username = item.Username;
            frmEdit.Mac = item.Mac;
            frmEdit.Ip = item.Ip;
            var result = frmEdit.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                item.Ip = frmEdit.Ip;
                item.Username = frmEdit.Username;
                item.Mac = frmEdit.Mac;
                int index = listIpAddresses.SelectedIndex;
                listIpAddresses.Items.RemoveAt(index);
                listIpAddresses.Items.Insert(index, item);
            }
        }