Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void BaudRate_SelectedIndexChanged(object sender, EventArgs e)
       {
           if ((CamPort.IsOpen)) CamPort.Close();
           if (BaudRate.SelectedIndex == -1) return;
           if (string.IsNullOrWhiteSpace(BaudRate.Text)) return;
           //CamPort.BaudRate =(int)BaudRate.Text;
           CamPort.Open();

       }
Posted
Updated 30-Jan-13 9:13am
v3
Comments
Sergey Alexandrovich Kryukov 24-Jan-13 16:54pm    
What did you try? It would be quicker to try and do it than asking...
—SA
Sergey Alexandrovich Kryukov 24-Jan-13 16:55pm    
What is "CamPort"? :-) First of all, tag the UI library you use. Forms? WPF? ASP.NET? Silverlight? something else?
—SA

1 solution

From your code it looks like what you really want is to parse the selected value like so:
C#
CamPort.BaudRate = int.Parse(BaudRate.Text);


If you wanted to use the selected index as your title suggests then you would just use it:
C#
CamPort.BaudRate = BaudRate.SelectedIndex

...But then your value would only be 0,1,2,etc
 
Share this answer
 
v2
Comments
lovely phantom 24-Jan-13 17:11pm    
Thanks :))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900