Thursday, December 4, 2008

List the names of all the computers in the network on a combobox



In this simple article you will learn how you can bring the IP address's of all the machines in a local network on to a combobox

Create a C# windows application project.Insert a combobox into the form

using System;
using System.Net;


Insert the code below into the page load of the form


String strHostName = Dns.GetHostName();
Console.WriteLine("Host Name: " + strHostName);

// Find host by name
IPHostEntry iphostentry = Dns.GetHostByName(strHostName);

// Enumerate IP addresses
int nIP = 0;
foreach(IPAddress ipaddress in iphostentry.AddressList)
{
combobox1.items.add(ipaddress.ToString());
}

No comments: