Take variable from one form and pull into the other form

Asked

Viewed 37 times

-1

Good night, I’m racking my brain on how to take the value of a form and store it in a variable so I can access that value in any other form.

I tried already as public Static instantiating but did not succeed the value returns null.

I appreciate any help.

  • is duplicated...only remaining to decide which one: https://answall.com/search?q=%5Bc%23%5D+form+value

1 answer

0

Good morning Carlos.

Although this is not good practice, you can create a static class that stores the values you need.

public static class RepVariaveis
{
    public static string MeuValor { get; set; }
}

So, in the first form, just assign the default value in the Repvariables class.

RepVariaveis.MeuValor = "xxxx";

However, this type of practice is not good because in a scenario with a large amount of Forms, it can become complicated generate

Browser other questions tagged

You are not signed in. Login or sign up in order to post.