SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 241 | Next

Jan Axelson

"Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems"

DataSource = bitRates;
The combo box displays the bit rates as text.
To initialize a combo box with flow-control methods, add each item to the
combo box:
 cmbHandshaking.Items.Add(Handshake.None)
cmbHandshaking.Items.Add(Handshake.XOnXOff)
cmbHandshaking.Items.Add(Handshake.RequestToSend)
cmbHandshaking.Items.Add(Handshake.RequestToSendXOnXOff)
 cmbHandshaking.Items.Add( Handshake.None );
cmbHandshaking.Items.Add( Handshake.XOnXOff );
cmbHandshaking.Items.Add( Handshake.RequestToSend );
cmbHandshaking.Items.Add( Handshake.RequestToSendXOnXOff );
The combo box displays the ToString property of each Handshake object.
In similar ways, you can add combo boxes for setting the number of data bits,
parity, and Stop bits as needed.
Chapter 10
224
A combo box??™s SelectedItem property contains the selected item expressed as
text, which code can convert to other object types as needed:
 ' Get the selected bit rate as an Integer.
Dim myBitRate As Integer = _
CInt(cmbBitRate.SelectedItem)
' Get the selected flow-control method as a Handshake object.
Dim myHandshake As Handshake = _
DirectCast(cmbHandshaking.SelectedItem, Handshake)
Console.WriteLine(myBitRate)
Console.WriteLine(myHandshake.ToString)
 // Get the selected bit rate as an Integer.
int myBitRate = (int)(cmbBitRate.SelectedItem);
// Get the selected flow-control method as a Handshake object.


Pages:
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253