Add a try-catch clause in your code.
You might have a hidden error in Form1_Load.
private void Form1_Load(object sender, EventArgs e)
{
try
{
serialPort1.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
[Update]
You need to show the form to activate Form_Load.
private void button1_Click(object sender, EventArgs e)
{
Form1 F = new Form1();
F.Show();
F.SerialPortValueUpdated();
}
This is not the best way to start a form with in a form.
Look into using a background worker instead.
BackgroundWorker Class[
^]
But it depends what you want to do.
[Update]
For logging and status of your serial communication, I recommend to use
Portmon[
^] from Sysinternals
Additional reading:
Simple Serial Communication with Microsoft Visual C# Express[
^]
How To Work With C# Serial Port Communication[
^]
Serial Port Communication In C#[
^]