private void loadPortsName() { cboPorts.Items.Clear(); string[] arrComPortNames = null; int index = -1; string stComPortName = null; //Com Ports arrComPortNames = RFIDReader.GetPortsName(); if (arrComPortNames.Length > 0) { do { index += 1; cboPorts.Items.Add(arrComPortNames[index]); }while (!((arrComPortNames[index] == stComPortName) || (index == arrComPortNames.GetUpperBound(0)))); Array.Sort(arrComPortNames); if (index == arrComPortNames.GetUpperBound(0)) { stComPortName = arrComPortNames[0]; } //get first item print in text cboPorts.Text = arrComPortNames[0]; } }