You can create a property of your class type in the form you want to receive the object and pass the object in the form builder, see an example below.
Form that will receive the object:
public partial class Form2 : Form
{
private User user;
public Form2(User user)
{
InitializeComponent();
this.user = user;
}
}
And the form that will send the object to the form it is calling:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
User user = new User
{
User_ID = 1,
Name = "Fulano",
Email = "[email protected]"
};
var form = new Form2(user);
form.Show();
}
}
This way you can manipulate the values of your object within the form without any kind of interference.
Thank you very much!
– Gabriel Longatti