Managing Ports and Transfers in .NET
In the application’s main form, specify a routine that will execute when the
event is raised. PortSettingsDialog is the form containing the combo boxes, and
SetPortParameters is the routine to execute:
AddHandler PortSettingsDialog.UserInterfacePortSettings, AddressOf SetPortParameters
PortSettingsDialog.UserInterfacePortSettings += new
PortSettingsDialog.UserInterfacePortSettingsEventHandler(SetPortParameters);
The SetPortParameters routine does whatever is needed with the passed param-
eters. For example, the routine can set the passed parameters on a SerialPort
object:
Private Sub SetPortParameters(ByVal userPort As String, ByVal userBitRate As Integer, _
ByVal userHandshake As Handshake)
UserPort1.SelectedPort.PortName = userPort
UserPort1.SelectedPort.BaudRate = userBitRate
UserPort1.SelectedPort.Handshake = userHandshake
End Sub
private void SetPortParameters
(string userPort, int userBitRate, Handshake userHandshake)
{
UserPort1.SelectedPort.PortName = userPort;
UserPort1.SelectedPort.BaudRate = userBitRate;
UserPort1.SelectedPort.Handshake = userHandshake;
}