示例#1
0
 private void cmdEdit_Click(object sender, EventArgs e)
 {
     if (lvwHosts.SelectedItems.Count > 0)
     {
         EditHostAddress editHostAddress = new EditHostAddress();
         editHostAddress.HostEntry = (HostEntry)lvwHosts.SelectedItems[0].Tag;
         if (editHostAddress.ShowHostAddress() == DialogResult.OK)
         {
             lvwHosts.SelectedItems[0].Text             = editHostAddress.HostEntry.HostName;
             lvwHosts.SelectedItems[0].SubItems[1].Text = editHostAddress.HostEntry.MaxTime.ToString();
             lvwHosts.SelectedItems[0].SubItems[2].Text = editHostAddress.HostEntry.TimeOut.ToString();
             lvwHosts.SelectedItems[0].SubItems[3].Text = editHostAddress.HostEntry.Description;
             lvwHosts.SelectedItems[0].Tag = editHostAddress.HostEntry;
         }
     }
 }
示例#2
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            EditHostAddress editHostAddress = new EditHostAddress();

            editHostAddress.HostEntry = new HostEntry();

            if (editHostAddress.ShowHostAddress() == DialogResult.OK)
            {
                ListViewItem lvi = new ListViewItem(editHostAddress.HostEntry.HostName);
                lvi.SubItems.Add(editHostAddress.HostEntry.MaxTime.ToString());
                lvi.SubItems.Add(editHostAddress.HostEntry.TimeOut.ToString());
                lvi.SubItems.Add(editHostAddress.HostEntry.Description);
                lvi.Tag = editHostAddress.HostEntry;
                lvwHosts.Items.Add(lvi);
            }
        }