-1
I’m developing a C# project and I’m stuck in a mistake when it comes to moving from one form to another. The main form is called Main and the new Form1... well... I can send a variable string to another, but then it does not execute anything other than message box.
Form1 = sending to Main
public void Button1_Click(object sender, EventArgs e)
{
string pid = ltBox.SelectedItem.ToString();
string valor = ltBox.SelectedItem.ToString();
pid = pid.Substring(0, pid.IndexOf('-', 0));
if (!pid.Equals(""))
{
Main destino = new Main();
destino.funcao(valor);
this.Hide();
}
}
Main receiving useless form...
public void funcao(string valor) {
MessageBox.Show("deu certo uhuuu sqn");
label1.Text = valor;
}
Unfortunately I can get the message that it worked, but the label1 does not change, and nothing else I do besides messagebox seems to work... someone can give a help there???
You have prompted a new class object
Main
, but you didn’t execute the methoddestino.Show()
to display the form.– Pedro Paulo
missing put . Show()
– Danielle Arruda torres
But then, the Form1 is to be a secondary form, I did not give IDE to open another
– Emilly Monteiro