Answer the question
In order to leave comments, you need to log in
How to add ListView column content to variable list?
Good afternoon,
I load a list of addresses from a text file into the program line by line
private void AddIPMassConfig_btn_Click(object sender, EventArgs e)
{
OpenFileDialog OpenDialog = new OpenFileDialog();
OpenDialog.Title = "Open IP List File";
OpenDialog.Filter = "text files|*.txt";
if (OpenDialog.ShowDialog() == DialogResult.OK)
{
foreach (string line in File.ReadAllLines(OpenDialog.FileName, Encoding.ASCII))
MassConfigIPList.Items.Add(new ListViewItem(line));
IPaddCount_label.Text = MassConfigIPList.Items.Count.ToString();
}
!!!! string[] Hosts = MassConfigIPList.Items.AddRange(MassConfigIPList.Items());
Hosts.Add(MassConfigIPList.Items[2].Text);
Hosts.Add(MassConfigIPList.Items[3].Text);
foreach (string Host in Hosts)
//foreach (string line in MassConfigIPList.Items)
{
//string Host = MassConfigIPList.FocusedItem.SubItems[0].Text;
//byte[] buffer = Encoding.ASCII.GetBytes(Host);
//pingReply = switchPing.Send(Host, timeout, buffer, options);
if (pingReply.Status == IPStatus.Success)
{
MassConfigIPList.Items[0].SubItems.Add("Ok");
//LiveCount_label.Text = LiveList.Items.Count.ToString();
}
else
{
//MassConfigIPList.Items[0].SubItems.Add("Bad");
//continue;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question