Click here to Skip to main content
15,891,713 members
Home / Discussions / C#
   

C#

 
GeneralRe: Reg: Crystal Report Pin
Dotnetkanna5-May-10 0:17
Dotnetkanna5-May-10 0:17 
GeneralRe: Reg: Crystal Report Pin
Eddy Vluggen5-May-10 0:56
professionalEddy Vluggen5-May-10 0:56 
GeneralRe: Reg: Crystal Report Pin
Dotnetkanna5-May-10 2:56
Dotnetkanna5-May-10 2:56 
GeneralRe: Reg: Crystal Report Pin
Eddy Vluggen5-May-10 5:00
professionalEddy Vluggen5-May-10 5:00 
QuestionINotifyPropertyChanged Question. Pin
Siddhartha S.4-May-10 19:04
Siddhartha S.4-May-10 19:04 
AnswerRe: INotifyPropertyChanged Question. Pin
Dan Mos4-May-10 19:19
Dan Mos4-May-10 19:19 
AnswerRe: INotifyPropertyChanged Question. Pin
AspDotNetDev4-May-10 19:57
protectorAspDotNetDev4-May-10 19:57 
QuestionUsing List for combo box collection [modified] Pin
mprice2144-May-10 17:53
mprice2144-May-10 17:53 
Hi all,

I've been trying to create a List that I want to use to populate a combo box collection. Frankly, I have no idea how to do this and have googled for quite some time trying to get a clue. Not to mention the whole List vs. IList, IEnumerable, etc. that I haven't even considered, but stumbled upon during my search. I have the code below, but I'm doing something wrong because I'm not able to call the list in a form load method.

public List<string> GetSerialDevice()
        {

            // Get a list of serial port names.
            
            
            strPorts = SerialPort.GetPortNames();

            List<string> strAmplifiers = new List<string>();

            //Console.WriteLine("The following serial ports were found:" );

        //    // Display each port name to the console.
        //    foreach (string strPort in strPorts)
        //    {
        //        Console.WriteLine(strPort);
        //    }
            


            foreach (string strPort in strPorts)
            {
                serialPort1 = new SerialPort(strPort, 115200, Parity.None, 8, StopBits.One);
                serialPort1.Handshake = Handshake.None;
                serialPort1.Close();
                serialPort1.ReadTimeout = 500;
                serialPort1.WriteTimeout = 500;
                serialPort1.Open();
                serialPort1.WriteLine("!001:USR1?\r");
                string strUSR1Return = serialPort1.ReadTo("\r");

                //Console.WriteLine(USR1Return);


                //Each unit will need to have 2.0 written to USR1 for this to work properly
                if (strUSR1Return == "+2.000000")
                {
                    serialPort1.WriteLine("!001:SERL?\r");
                    string strSerialLow = serialPort1.ReadTo("\r");
                    serialPort1.WriteLine("!001:SERH?\r");
                    string strSerialHigh = serialPort1.ReadTo("\r");
                    //SN coding per mfg
                    double dblSerialNumber = double.Parse(strSerialHigh) * 65536 + double.Parse(strSerialLow);
                    Console.WriteLine("On" + " " + strPort + " " + "there is a valid amplifier with S/N "
                        + dblSerialNumber.ToString());

                    strAmplifiers.Add(dblSerialNumber.ToString());
                    
                                           
                }//End of if
                
            }//End of foreach
            Console.WriteLine(strAmplifiers[0]);

            serialPort1.Close();

            return strAmplifiers;


modified on Wednesday, May 5, 2010 12:02 AM

AnswerRe: Using List for combo box collection Pin
Luc Pattyn4-May-10 18:19
sitebuilderLuc Pattyn4-May-10 18:19 
GeneralRe: Using List for combo box collection Pin
mprice2144-May-10 18:40
mprice2144-May-10 18:40 
GeneralRe: Using List for combo box collection Pin
Dan Mos4-May-10 18:56
Dan Mos4-May-10 18:56 
QuestionCalibration and Tolerance Pin
jokerleo4-May-10 17:32
jokerleo4-May-10 17:32 
AnswerRe: Calibration and Tolerance Pin
Luc Pattyn4-May-10 18:21
sitebuilderLuc Pattyn4-May-10 18:21 
GeneralRe: Calibration and Tolerance Pin
jokerleo4-May-10 20:11
jokerleo4-May-10 20:11 
GeneralRe: Calibration and Tolerance Pin
Luc Pattyn5-May-10 2:44
sitebuilderLuc Pattyn5-May-10 2:44 
GeneralRe: Calibration and Tolerance Pin
Dave Kreskowiak5-May-10 4:22
mveDave Kreskowiak5-May-10 4:22 
QuestionReading standardoutput to a file Pin
svanwass4-May-10 14:06
svanwass4-May-10 14:06 
AnswerRe: Reading standardoutput to a file Pin
Dan Mos4-May-10 14:54
Dan Mos4-May-10 14:54 
GeneralRe: Reading standardoutput to a file Pin
svanwass4-May-10 15:00
svanwass4-May-10 15:00 
GeneralRe: Reading standardoutput to a file Pin
Dan Mos4-May-10 16:21
Dan Mos4-May-10 16:21 
GeneralRe: Reading standardoutput to a file Pin
Luc Pattyn4-May-10 16:37
sitebuilderLuc Pattyn4-May-10 16:37 
GeneralRe: Reading standardoutput to a file Pin
Dan Mos4-May-10 16:51
Dan Mos4-May-10 16:51 
GeneralRe: Reading standardoutput to a file Pin
Luc Pattyn4-May-10 17:00
sitebuilderLuc Pattyn4-May-10 17:00 
GeneralRe: Reading standardoutput to a file Pin
Dan Mos4-May-10 17:06
Dan Mos4-May-10 17:06 
GeneralRe: Reading standardoutput to a file Pin
Luc Pattyn4-May-10 17:09
sitebuilderLuc Pattyn4-May-10 17:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.