private void toolStripButton5_Click(object sender, EventArgs e) { listView1.Items.Clear(); foreach (Host host in HostsParse.ParseList()) { ListViewItem listViewItem = new ListViewItem(new string[] { host.IP, host.Domain }); listViewItem.Tag = host; listView1.Items.Add(listViewItem); } }
private void MainForm_Load(object sender, EventArgs e) { if (!HostsParse.HostsExists()) { MessageBox.Show("系统hosts文件不存在!", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } foreach (Host host in HostsParse.ParseList()) { ListViewItem listViewItem = new ListViewItem(new string[] { host.IP, host.Domain }); listViewItem.Tag = host; listView1.Items.Add(listViewItem); } }