Click here to Skip to main content
15,900,724 members
Home / Discussions / C#
   

C#

 
QuestionHow to retrive message list from p2p Pin
Saiyed Alam4-May-10 20:56
Saiyed Alam4-May-10 20:56 
QuestionListBox Controls Pin
Illegal Operation4-May-10 20:22
Illegal Operation4-May-10 20:22 
AnswerRe: ListBox Controls [modified] Pin
Dan Mos4-May-10 20:43
Dan Mos4-May-10 20:43 
AnswerRe: ListBox Controls Pin
Henry Minute5-May-10 2:56
Henry Minute5-May-10 2:56 
QuestionAdd column to excel Pin
yadlaprasad4-May-10 20:03
yadlaprasad4-May-10 20:03 
AnswerRe: Add column to excel Pin
Dan Mos4-May-10 20:16
Dan Mos4-May-10 20:16 
AnswerRe: Add column to excel Pin
yadlaprasad4-May-10 20:22
yadlaprasad4-May-10 20:22 
GeneralRe: Add column to excel Pin
Estys4-May-10 21:07
Estys4-May-10 21:07 
QuestionReg: Crystal Report Pin
Dotnetkanna4-May-10 19:21
Dotnetkanna4-May-10 19:21 
AnswerRe: Reg: Crystal Report Pin
Eddy Vluggen4-May-10 23:27
professionalEddy Vluggen4-May-10 23:27 
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 

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.