コード例 #1
0
 private void cbServerName_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbServerName.Items[cbServerName.SelectedIndex].ToString() == "<Browser for more...>")
     {
         ServersBrowser browser = new ServersBrowser();
         browser.ShowDialog();
         if (browser.DialogResult == DialogResult.OK)
         {
             if (cbServerName.Items.Count > countRecords)
             {
                 cbServerName.Items.RemoveAt(0);
             }
             strServerName = browser.ServerName;
             if (cbServerName.FindString(browser.ServerName, 0) == -1)
             {
                 cbServerName.Items.Insert(0, browser.ServerName);
                 cbServerName.SelectedIndex = 0;
             }
         }
         else
         {
             cbServerName.SelectedIndex = 0;
             strServerName = cbServerName.Items[cbServerName.SelectedIndex].ToString();
         }
     }
     else
     {
         strServerName = cbServerName.Items[cbServerName.SelectedIndex].ToString();
     }
 }
コード例 #2
0
        private void Connection_Load(object sender, EventArgs e)
        {
            List <string> lLocalServers = ServersBrowser.LocalServersList();

            foreach (string item in lLocalServers)
            {
                cbServerName.Items.Add(item);
            }
            cbServerName.Items.Add("<Browser for more...>");
            countRecords = cbServerName.Items.Count;
            if (countRecords == 1)
            {
                //If no local server exists add empty string in the list
                cbServerName.Items.Insert(0, "");
            }
            cbServerName.SelectedIndex     = 0;
            cbAuthentication.SelectedIndex = 0;
        }