Click here to Skip to main content
12,399,640 members (50,237 online)
Rate this:
 
Please Sign up or sign in to 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 24-Jan-13 10:49am
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

If you wanted to use the selected index as your title suggests then you would just use it:
CamPort.BaudRate = BaudRate.SelectedIndex
...But then your value would only be 0,1,2,etc
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100