コード例 #1
0
        /// <summary>
        /// fill the network combo box list with a custom combo box item
        /// </summary>
        /// <param name="vSelectedNetworkName"></param>
        /// <param name="vConnectivity"></param>
        private void FillNetworkList(string vSelectedNetworkName, NetworkConnectivityLevels vConnectivity)
        {
            cbNetwork.Items.Clear();

            NetworkCollection  netCollection = NetworkListManager.GetNetworks(vConnectivity); // NetworkConnectivityLevels.Connected);
            ComboboxItemCustom comboItem;

            var orderedList =
                netCollection.OrderBy(x => x.Name);

            //.ThenByDescending(x => x.Name);

            foreach (Network n in orderedList)
            {
                {
                    comboItem = new ComboboxItemCustom(n.Name, n.NetworkId.ToString(), n.IsConnectedToInternet);
                    cbNetwork.Items.Add(comboItem);

                    if (vSelectedNetworkName == n.Name)
                    {
                        cbNetwork.SelectedItem = comboItem;
                    }
                }
            }

            if (String.IsNullOrEmpty(vSelectedNetworkName))
            {
                cbNetwork.Text = "(Select One)";
            }
        }