示例#1
0
 private void frmMain_Load(object sender, EventArgs e)
 {
     //create a new NetworkBrowser object, and get the
     //list of network computers it found, and add each
     //entry to the combo box on this form
     try
     {
         NetworkBrowser nb = new NetworkBrowser();
         foreach (string pc in nb.getNetworkComputers())
         {
             cmbNetworkComputers.Items.Add(pc);
         }
     }
     catch (Exception ex) {
         MessageBox.Show("An error occurred trying to access the network computers", "error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         Application.Exit();
     }
 }
示例#2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            //create a new NetworkBrowser object, and get the
            //list of network computers it found, and add each
            //entry to the combo box on this form
            try
            {
                NetworkBrowser nb     = new NetworkBrowser();
                ArrayList      pcList = nb.getNetworkComputers();

                IEnumerator myEnum = pcList.GetEnumerator();


                int i = 0;
                while (myEnum.MoveNext())
                {
                    Pair pair = new Pair(i, myEnum.Current.ToString());
                    computeList.Add(pair);
                    i++;
                }

                //foreach (string pc in myEnum)
                //{
                //computeList.Add();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred trying to access the network computers", "error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            finally
            {
                //dataGridView1.

                dataGridView1.Columns.Add("key", "Номер ПЭВМ");
                dataGridView1.Columns.Add("value", "Имя ПЭВМ");

                dataGridView1.DataSource = computeList;
            }
        }
示例#3
0
 private void button7_Click(object sender, EventArgs e)
 {
     listBox1.Visible = true;
     label5.Visible = true;
     label5.Text = "CONNECTED ROUTES";
     //label5.Visible = false;
     groupBox1.Visible = false;
     try
     {//used to get network system names from Lan connection
         NetworkBrowser nb = new NetworkBrowser();
         foreach (string pc in nb.getNetworkComputers())
         {
             listBox1.Items.Add(pc);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("An error occurred trying to access the network computers", "error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
         Application.Exit();
     }
 }