2
Good afternoon, I’m a few days cracking my head here. I’m developing an app with 2 Forms (screens). On the home screen is login, and the second screen is the app itself. I want to take the name entered by the user in the Txtbox of the home screen, and move to a label of the second screen, getting: Welcome(a) {usersname}!
I debugged the code, and for some reason, the labelWelcome variable initially receives the value, however, it does not receive the variable, the correct mode would be: labelWelcome.Text = $"Welcome(a) {Username}";
But she receives only: labelWelcome.Text = $"Welcome(to)";
DETAIL: The Username var does receive the value of FORM1, why is it not going on the FORM2 label?
It follows logic I used to pass the values:
**FORM1 (LOGIN):**
                // Método para abrir a nova tela
                private void FormLogado()
                {
                Application.Run(new CronogramaLogado(btn_login.Text));
                }
                *// Codificação para abrir nova tela
                Logado = new Thread(FormLogado);
                Logado.SetApartmentState(ApartmentState.STA);
                
                // String que recebe o nome do usuário da txtbox
                string nomeusuario = btn_login.Text;
                // instanciação da tela 2 chamada CronogramaLogado, e passando o valor do nome do user
                CronogramaLogado nome = new CronogramaLogado(nomeusuario);
                // "this.Close() fecha a tela anterior, e mantém somente a nova aberta"
                this.Close();
                // Abre a nova tela
                Logado.Start();*
FORM 2 (APP AFTER LOGGING):
public partial class CronogramaLogado : Form
{
    public string Username;
    // Obrigando passar o valor username quando chamar a segunda tela
    public CronogramaLogado(string username)
    {
        InitializeComponent();
        Username = username;
        labelWelcome.Text = $"Seja bem-vindo(a) {Username}";
        // Método para gerar as colunas assim que a tela é aberta
        GerarColunas();
    }
}
Unfortunately it hasn’t worked yet. In " var schedule = Timelogged " says I can’t use Timelogged in the given context. The way I made up the Form2 vars get value, however, in the =/
– Gabriel
ah in my example missed the new :) already edited the question
– Ricardo Pontual