Hi dear, Check this information.
Your declarative function name is " private void loadPorts() " but form1 function used another form then function name is declare as " public void loadPorts() " not declare " private void loadPorts() " .
public void loadPorts()
{
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
cboPorts.Items.Add(port);
}
}
//--------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SMS;
using System.IO.Ports;
using System.Threading;
namespace WindowsFormsAppDAL
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2 _Load(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.loadPorts();
}